Skip to content

WindowsCopyPathCommand

Base classes

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

⋔ Inheritance diagram

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

🛈 DocStrings

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

:fa-brands-github: Show source on GitHub