Skip to content

UnixCopyPathCommand

Base classes

Name Children Inherits
CopyPathCommand
anyenv.os_commands.base
Base class for copy path commands.

⋔ Inheritance diagram

graph TD
  581921880["copy_path.UnixCopyPathCommand"]
  2819545931["base.CopyPathCommand"]
  925645236["abc.ABC"]
  2751680898["builtins.object"]
  2819545931 --> 581921880
  925645236 --> 2819545931
  2751680898 --> 925645236

🛈 DocStrings

Bases: CopyPathCommand

Unix/Linux copy path command implementation.

Source code in src/anyenv/os_commands/copy_path.py
class UnixCopyPathCommand(CopyPathCommand):
    """Unix/Linux copy path command implementation."""

    def create_command(self, source: str, destination: str, recursive: bool = False) -> str:
        """Generate Unix cp command.

        Args:
            source: Source path to copy from
            destination: Destination path to copy to
            recursive: Whether to copy directories recursively

        Returns:
            The cp command string
        """
        if recursive:
            return f"cp -r {sh_path(source)} {sh_path(destination)}"
        return f"cp {sh_path(source)} {sh_path(destination)}"

    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse Unix cp result based on exit code.

        Args:
            output: Raw command output (ignored)
            exit_code: Command exit code

        Returns:
            True if copy was successful, False otherwise
        """
        return exit_code == 0

create_command

create_command(source: str, destination: str, recursive: bool = False) -> str

Generate Unix cp command.

Parameters:

Name Type Description Default
source str

Source path to copy from

required
destination str

Destination path to copy to

required
recursive bool

Whether to copy directories recursively

False

Returns:

Type Description
str

The cp command string

Source code in src/anyenv/os_commands/copy_path.py
def create_command(self, source: str, destination: str, recursive: bool = False) -> str:
    """Generate Unix cp command.

    Args:
        source: Source path to copy from
        destination: Destination path to copy to
        recursive: Whether to copy directories recursively

    Returns:
        The cp command string
    """
    if recursive:
        return f"cp -r {sh_path(source)} {sh_path(destination)}"
    return f"cp {sh_path(source)} {sh_path(destination)}"

parse_command

parse_command(output: str, exit_code: int = 0) -> bool

Parse Unix cp result based on exit code.

Parameters:

Name Type Description Default
output str

Raw command output (ignored)

required
exit_code int

Command exit code

0

Returns:

Type Description
bool

True if copy was successful, False otherwise

Source code in src/anyenv/os_commands/copy_path.py
def parse_command(self, output: str, exit_code: int = 0) -> bool:
    """Parse Unix cp result based on exit code.

    Args:
        output: Raw command output (ignored)
        exit_code: Command exit code

    Returns:
        True if copy was successful, False otherwise
    """
    return exit_code == 0

:fa-brands-github: Show source on GitHub