Skip to content

UnixRemovePathCommand

Base classes

Name Children Inherits
RemovePathCommand
anyenv.os_commands.base
Base class for remove path commands.

⋔ Inheritance diagram

graph TD
  2691124851["remove_path.UnixRemovePathCommand"]
  691014020["base.RemovePathCommand"]
  925645236["abc.ABC"]
  2751680898["builtins.object"]
  691014020 --> 2691124851
  925645236 --> 691014020
  2751680898 --> 925645236

🛈 DocStrings

Bases: RemovePathCommand

Unix/Linux remove path command implementation.

Source code in src/anyenv/os_commands/remove_path.py
class UnixRemovePathCommand(RemovePathCommand):
    """Unix/Linux remove path command implementation."""

    def create_command(self, path: str, recursive: bool = False) -> str:
        """Generate Unix rm command.

        Args:
            path: Path to remove
            recursive: Whether to remove directories recursively

        Returns:
            The rm command string
        """
        return f"rm -rf {sh_path(path)}" if recursive else f"rm {sh_path(path)}"

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

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

        Returns:
            True if path was removed successfully, False otherwise
        """
        return exit_code == 0

create_command

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

Generate Unix rm command.

Parameters:

Name Type Description Default
path str

Path to remove

required
recursive bool

Whether to remove directories recursively

False

Returns:

Type Description
str

The rm command string

Source code in src/anyenv/os_commands/remove_path.py
def create_command(self, path: str, recursive: bool = False) -> str:
    """Generate Unix rm command.

    Args:
        path: Path to remove
        recursive: Whether to remove directories recursively

    Returns:
        The rm command string
    """
    return f"rm -rf {sh_path(path)}" if recursive else f"rm {sh_path(path)}"

parse_command

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

Parse Unix rm 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 path was removed successfully, False otherwise

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

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

    Returns:
        True if path was removed successfully, False otherwise
    """
    return exit_code == 0

:fa-brands-github: Show source on GitHub