Skip to content

copy_path

Class info

Classes

Name Children Inherits
MacOSCopyPathCommand
anyenv.os_commands.copy_path
macOS copy path command implementation.
    UnixCopyPathCommand
    anyenv.os_commands.copy_path
    Unix/Linux copy path command implementation.
      WindowsCopyPathCommand
      anyenv.os_commands.copy_path
      Windows copy path command implementation.

        🛈 DocStrings

        Copy path command implementations for different operating systems.

        MacOSCopyPathCommand

        Bases: CopyPathCommand

        macOS copy path command implementation.

        Source code in src/anyenv/os_commands/copy_path.py
        class MacOSCopyPathCommand(CopyPathCommand):
            """macOS copy path command implementation."""
        
            def create_command(self, source: str, destination: str, recursive: bool = False) -> str:
                """Generate cp command (same as Unix).
        
                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 cp result based on exit code (same as Unix).
        
                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 cp command (same as Unix).

        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 cp command (same as Unix).
        
            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 cp result based on exit code (same as Unix).

        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 cp result based on exit code (same as Unix).
        
            Args:
                output: Raw command output (ignored)
                exit_code: Command exit code
        
            Returns:
                True if copy was successful, False otherwise
            """
            return exit_code == 0
        

        UnixCopyPathCommand

        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
        

        WindowsCopyPathCommand

        Bases: CopyPathCommand

        Windows copy path command implementation.

        Source code in src/anyenv/os_commands/copy_path.py
        class WindowsCopyPathCommand(CopyPathCommand):
            """Windows copy path command implementation."""
        
            def create_command(self, source: str, destination: str, recursive: bool = False) -> str:
                """Generate Windows copy command.
        
                Args:
                    source: Source path to copy from
                    destination: Destination path to copy to
                    recursive: Whether to copy directories recursively
        
                Returns:
                    The copy command string
                """
                script = f"Copy-Item -LiteralPath {ps_literal(source)} {ps_literal(destination)} -Force"
                return powershell(f"{script} -Recurse" if recursive else script)
        
            def parse_command(self, output: str, exit_code: int = 0) -> bool:
                """Parse Windows copy result.
        
                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 Windows copy 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 copy 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 Windows copy command.
        
            Args:
                source: Source path to copy from
                destination: Destination path to copy to
                recursive: Whether to copy directories recursively
        
            Returns:
                The copy command string
            """
            script = f"Copy-Item -LiteralPath {ps_literal(source)} {ps_literal(destination)} -Force"
            return powershell(f"{script} -Recurse" if recursive else script)
        

        parse_command

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

        Parse Windows copy result.

        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 Windows copy result.
        
            Args:
                output: Raw command output (ignored)
                exit_code: Command exit code
        
            Returns:
                True if copy was successful, False otherwise
            """
            return exit_code == 0