Skip to content

base

Class info

Classes

Name Children Inherits
Base64EncodeCommand
anyenv.os_commands.base
Base class for base64 encode commands.
CommandProtocol
anyenv.os_commands.base
Protocol for all OS commands.
    CopyPathCommand
    anyenv.os_commands.base
    Base class for copy path commands.
    CreateDirectoryCommand
    anyenv.os_commands.base
    Base class for create directory commands.
    EnvVarCommand
    anyenv.os_commands.base
    Base class for environment variable commands.
    ExistsCommand
    anyenv.os_commands.base
    Base class for exists commands.
    FileInfoCommand
    anyenv.os_commands.base
    Base class for file info commands.
    FindCommand
    anyenv.os_commands.base
    Base class for recursive find commands.
    IsDirectoryCommand
    anyenv.os_commands.base
    Base class for is directory commands.
    IsFileCommand
    anyenv.os_commands.base
    Base class for is file commands.
    ListDirectoryCommand
    anyenv.os_commands.base
    Base class for list directory commands.
    PwdCommand
    anyenv.os_commands.base
    Base class for pwd (print working directory) commands.
    RemovePathCommand
    anyenv.os_commands.base
    Base class for remove path commands.
    WhichCommand
    anyenv.os_commands.base
    Base class for which/where commands to locate executables.

    🛈 DocStrings

    Base protocol and classes for OS-specific commands.

    Base64EncodeCommand

    Bases: ABC

    Base class for base64 encode commands.

    Source code in src/anyenv/os_commands/base.py
    class Base64EncodeCommand(ABC):
        """Base class for base64 encode commands."""
    
        @abstractmethod
        def create_command(self, path: str) -> str:
            """Generate base64 encode command."""
    
        @abstractmethod
        def parse_command(self, output: str) -> bytes:
            """Parse base64 output and return decoded bytes."""
    

    create_command abstractmethod

    create_command(path: str) -> str
    

    Generate base64 encode command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str) -> str:
        """Generate base64 encode command."""
    

    parse_command abstractmethod

    parse_command(output: str) -> bytes
    

    Parse base64 output and return decoded bytes.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str) -> bytes:
        """Parse base64 output and return decoded bytes."""
    

    CommandProtocol

    Bases: Protocol

    Protocol for all OS commands.

    Source code in src/anyenv/os_commands/base.py
    class CommandProtocol(Protocol):
        """Protocol for all OS commands."""
    
        def create_command(self, *args: Any, **kwargs: Any) -> str:
            """Generate the OS-specific command string."""
            ...
    
        def parse_command(self, output: str, exit_code: int = 0, *args: Any, **kwargs: Any) -> Any:
            """Parse the command output."""
            ...
    

    create_command

    create_command(*args: Any, **kwargs: Any) -> str
    

    Generate the OS-specific command string.

    Source code in src/anyenv/os_commands/base.py
    def create_command(self, *args: Any, **kwargs: Any) -> str:
        """Generate the OS-specific command string."""
        ...
    

    parse_command

    parse_command(output: str, exit_code: int = 0, *args: Any, **kwargs: Any) -> Any
    

    Parse the command output.

    Source code in src/anyenv/os_commands/base.py
    def parse_command(self, output: str, exit_code: int = 0, *args: Any, **kwargs: Any) -> Any:
        """Parse the command output."""
        ...
    

    CopyPathCommand

    Bases: ABC

    Base class for copy path commands.

    Source code in src/anyenv/os_commands/base.py
    class CopyPathCommand(ABC):
        """Base class for copy path commands."""
    
        @abstractmethod
        def create_command(self, source: str, destination: str, recursive: bool = False) -> str:
            """Generate copy command.
    
            Args:
                source: Source path to copy from
                destination: Destination path to copy to
                recursive: Whether to copy directories recursively
            """
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> bool:
            """Parse copy result.
    
            Returns:
                True if copy was successful, False otherwise
            """
    

    create_command abstractmethod

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

    Generate 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
    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, source: str, destination: str, recursive: bool = False) -> str:
        """Generate copy command.
    
        Args:
            source: Source path to copy from
            destination: Destination path to copy to
            recursive: Whether to copy directories recursively
        """
    

    parse_command abstractmethod

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

    Parse copy result.

    Returns:

    Type Description
    bool

    True if copy was successful, False otherwise

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse copy result.
    
        Returns:
            True if copy was successful, False otherwise
        """
    

    CreateDirectoryCommand

    Bases: ABC

    Base class for create directory commands.

    Source code in src/anyenv/os_commands/base.py
    class CreateDirectoryCommand(ABC):
        """Base class for create directory commands."""
    
        @abstractmethod
        def create_command(self, path: str, parents: bool = True) -> str:
            """Generate directory creation command."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> bool:
            """Parse directory creation result."""
    

    create_command abstractmethod

    create_command(path: str, parents: bool = True) -> str
    

    Generate directory creation command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str, parents: bool = True) -> str:
        """Generate directory creation command."""
    

    parse_command abstractmethod

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

    Parse directory creation result.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse directory creation result."""
    

    EnvVarCommand

    Bases: ABC

    Base class for environment variable commands.

    Source code in src/anyenv/os_commands/base.py
    class EnvVarCommand(ABC):
        """Base class for environment variable commands."""
    
        @abstractmethod
        def create_command(self, name: str) -> str:
            """Generate command to get environment variable value."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> str | None:
            """Parse output and return variable value or None if not set."""
    

    create_command abstractmethod

    create_command(name: str) -> str
    

    Generate command to get environment variable value.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, name: str) -> str:
        """Generate command to get environment variable value."""
    

    parse_command abstractmethod

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

    Parse output and return variable value or None if not set.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> str | None:
        """Parse output and return variable value or None if not set."""
    

    ExistsCommand

    Bases: ABC

    Base class for exists commands.

    Source code in src/anyenv/os_commands/base.py
    class ExistsCommand(ABC):
        """Base class for exists commands."""
    
        @abstractmethod
        def create_command(self, path: str) -> str:
            """Generate exists test command."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> bool:
            """Parse exists test result."""
    

    create_command abstractmethod

    create_command(path: str) -> str
    

    Generate exists test command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str) -> str:
        """Generate exists test command."""
    

    parse_command abstractmethod

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

    Parse exists test result.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse exists test result."""
    

    FileInfoCommand

    Bases: ABC

    Base class for file info commands.

    Source code in src/anyenv/os_commands/base.py
    class FileInfoCommand(ABC):
        """Base class for file info commands."""
    
        @abstractmethod
        def create_command(self, path: str) -> str:
            """Generate file info command."""
    
        @abstractmethod
        def parse_command(self, output: str, path: str) -> FileInfo:
            """Parse file info output."""
    

    create_command abstractmethod

    create_command(path: str) -> str
    

    Generate file info command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str) -> str:
        """Generate file info command."""
    

    parse_command abstractmethod

    parse_command(output: str, path: str) -> FileInfo
    

    Parse file info output.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, path: str) -> FileInfo:
        """Parse file info output."""
    

    FindCommand

    Bases: ABC

    Base class for recursive find commands.

    Used for efficiently finding files/directories recursively in a single command, rather than walking the tree with multiple list operations.

    Source code in src/anyenv/os_commands/base.py
    class FindCommand(ABC):
        """Base class for recursive find commands.
    
        Used for efficiently finding files/directories recursively in a single
        command, rather than walking the tree with multiple list operations.
        """
    
        @abstractmethod
        def create_command(
            self,
            path: str,
            pattern: str | None = None,
            maxdepth: int | None = None,
            file_type: Literal["file", "directory", "all"] = "all",
            with_stats: bool = True,
        ) -> str:
            """Generate recursive find command.
    
            Args:
                path: Directory to search in
                pattern: Glob pattern for name matching (e.g., "*.py")
                maxdepth: Maximum directory depth to descend (None for unlimited)
                file_type: Filter by type - files only, directories only, or all
                with_stats: Include file stats (size, mtime, type, permissions)
            """
    
        @abstractmethod
        def parse_command(self, output: str, base_path: str = "") -> list[DirectoryEntry]:
            """Parse find output into DirectoryEntry objects.
    
            Args:
                output: Raw command output
                base_path: Base path used in the find command
    
            Returns:
                List of DirectoryEntry objects for found items
            """
    

    create_command abstractmethod

    create_command(
        path: str,
        pattern: str | None = None,
        maxdepth: int | None = None,
        file_type: Literal["file", "directory", "all"] = "all",
        with_stats: bool = True,
    ) -> str
    

    Generate recursive find command.

    Parameters:

    Name Type Description Default
    path str

    Directory to search in

    required
    pattern str | None

    Glob pattern for name matching (e.g., "*.py")

    None
    maxdepth int | None

    Maximum directory depth to descend (None for unlimited)

    None
    file_type Literal['file', 'directory', 'all']

    Filter by type - files only, directories only, or all

    'all'
    with_stats bool

    Include file stats (size, mtime, type, permissions)

    True
    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(
        self,
        path: str,
        pattern: str | None = None,
        maxdepth: int | None = None,
        file_type: Literal["file", "directory", "all"] = "all",
        with_stats: bool = True,
    ) -> str:
        """Generate recursive find command.
    
        Args:
            path: Directory to search in
            pattern: Glob pattern for name matching (e.g., "*.py")
            maxdepth: Maximum directory depth to descend (None for unlimited)
            file_type: Filter by type - files only, directories only, or all
            with_stats: Include file stats (size, mtime, type, permissions)
        """
    

    parse_command abstractmethod

    parse_command(output: str, base_path: str = '') -> list[DirectoryEntry]
    

    Parse find output into DirectoryEntry objects.

    Parameters:

    Name Type Description Default
    output str

    Raw command output

    required
    base_path str

    Base path used in the find command

    ''

    Returns:

    Type Description
    list[DirectoryEntry]

    List of DirectoryEntry objects for found items

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, base_path: str = "") -> list[DirectoryEntry]:
        """Parse find output into DirectoryEntry objects.
    
        Args:
            output: Raw command output
            base_path: Base path used in the find command
    
        Returns:
            List of DirectoryEntry objects for found items
        """
    

    IsDirectoryCommand

    Bases: ABC

    Base class for is directory commands.

    Source code in src/anyenv/os_commands/base.py
    class IsDirectoryCommand(ABC):
        """Base class for is directory commands."""
    
        @abstractmethod
        def create_command(self, path: str) -> str:
            """Generate directory test command."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> bool:
            """Parse directory test result."""
    

    create_command abstractmethod

    create_command(path: str) -> str
    

    Generate directory test command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str) -> str:
        """Generate directory test command."""
    

    parse_command abstractmethod

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

    Parse directory test result.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse directory test result."""
    

    IsFileCommand

    Bases: ABC

    Base class for is file commands.

    Source code in src/anyenv/os_commands/base.py
    class IsFileCommand(ABC):
        """Base class for is file commands."""
    
        @abstractmethod
        def create_command(self, path: str) -> str:
            """Generate file test command."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> bool:
            """Parse file test result."""
    

    create_command abstractmethod

    create_command(path: str) -> str
    

    Generate file test command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str) -> str:
        """Generate file test command."""
    

    parse_command abstractmethod

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

    Parse file test result.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse file test result."""
    

    ListDirectoryCommand

    Bases: ABC

    Base class for list directory commands.

    Source code in src/anyenv/os_commands/base.py
    class ListDirectoryCommand(ABC):
        """Base class for list directory commands."""
    
        @abstractmethod
        def create_command(self, path: str = "") -> str:
            """Generate directory listing command."""
    
        @abstractmethod
        def parse_command(self, output: str, path: str = "") -> list[DirectoryEntry]:
            """Parse directory listing output."""
    

    create_command abstractmethod

    create_command(path: str = '') -> str
    

    Generate directory listing command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str = "") -> str:
        """Generate directory listing command."""
    

    parse_command abstractmethod

    parse_command(output: str, path: str = '') -> list[DirectoryEntry]
    

    Parse directory listing output.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, path: str = "") -> list[DirectoryEntry]:
        """Parse directory listing output."""
    

    PwdCommand

    Bases: ABC

    Base class for pwd (print working directory) commands.

    Source code in src/anyenv/os_commands/base.py
    class PwdCommand(ABC):
        """Base class for pwd (print working directory) commands."""
    
        @abstractmethod
        def create_command(self) -> str:
            """Generate command to get current working directory."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> str | None:
            """Parse output and return current directory or None on failure."""
    

    create_command abstractmethod

    create_command() -> str
    

    Generate command to get current working directory.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self) -> str:
        """Generate command to get current working directory."""
    

    parse_command abstractmethod

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

    Parse output and return current directory or None on failure.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> str | None:
        """Parse output and return current directory or None on failure."""
    

    RemovePathCommand

    Bases: ABC

    Base class for remove path commands.

    Source code in src/anyenv/os_commands/base.py
    class RemovePathCommand(ABC):
        """Base class for remove path commands."""
    
        @abstractmethod
        def create_command(self, path: str, recursive: bool = False) -> str:
            """Generate removal command."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> bool:
            """Parse removal result."""
    

    create_command abstractmethod

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

    Generate removal command.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, path: str, recursive: bool = False) -> str:
        """Generate removal command."""
    

    parse_command abstractmethod

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

    Parse removal result.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> bool:
        """Parse removal result."""
    

    WhichCommand

    Bases: ABC

    Base class for which/where commands to locate executables.

    Source code in src/anyenv/os_commands/base.py
    class WhichCommand(ABC):
        """Base class for which/where commands to locate executables."""
    
        @abstractmethod
        def create_command(self, executable: str) -> str:
            """Generate command to find executable path."""
    
        @abstractmethod
        def parse_command(self, output: str, exit_code: int = 0) -> str | None:
            """Parse output and return executable path or None if not found."""
    

    create_command abstractmethod

    create_command(executable: str) -> str
    

    Generate command to find executable path.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def create_command(self, executable: str) -> str:
        """Generate command to find executable path."""
    

    parse_command abstractmethod

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

    Parse output and return executable path or None if not found.

    Source code in src/anyenv/os_commands/base.py
    @abstractmethod
    def parse_command(self, output: str, exit_code: int = 0) -> str | None:
        """Parse output and return executable path or None if not found."""