Skip to content

providers

Class info

Classes

Name Children Inherits
MacOSCommandProvider
anyenv.os_commands.providers
macOS command provider using BSD tools.
    OSCommandProvider
    anyenv.os_commands.providers
    Base class for OS-specific command providers using command classes.
    UnixCommandProvider
    anyenv.os_commands.providers
    Unix/Linux command provider using GNU/POSIX tools.
      WindowsCommandProvider
      anyenv.os_commands.providers
      Windows command provider using PowerShell and CMD.

        🛈 DocStrings

        OS-specific command providers using the command classes.

        MacOSCommandProvider

        Bases: OSCommandProvider

        macOS command provider using BSD tools.

        Source code in src/anyenv/os_commands/providers.py
        class MacOSCommandProvider(OSCommandProvider):
            """macOS command provider using BSD tools."""
        
            def __init__(self) -> None:
                """Initialize macOS command provider with macOS command instances."""
                super().__init__()
                self.commands = {
                    "list_directory": MacOSListDirectoryCommand(),
                    "file_info": MacOSFileInfoCommand(),
                    "exists": MacOSExistsCommand(),
                    "is_file": MacOSIsFileCommand(),
                    "is_directory": MacOSIsDirectoryCommand(),
                    "create_directory": MacOSCreateDirectoryCommand(),
                    "remove_path": MacOSRemovePathCommand(),
                    "copy_path": MacOSCopyPathCommand(),
                    "base64_encode": MacOSBase64EncodeCommand(),
                    "which": MacOSWhichCommand(),
                    "pwd": MacOSPwdCommand(),
                    "env_var": MacOSEnvVarCommand(),
                    "find": MacOSFindCommand(),
                }
        

        __init__

        __init__() -> None
        

        Initialize macOS command provider with macOS command instances.

        Source code in src/anyenv/os_commands/providers.py
        def __init__(self) -> None:
            """Initialize macOS command provider with macOS command instances."""
            super().__init__()
            self.commands = {
                "list_directory": MacOSListDirectoryCommand(),
                "file_info": MacOSFileInfoCommand(),
                "exists": MacOSExistsCommand(),
                "is_file": MacOSIsFileCommand(),
                "is_directory": MacOSIsDirectoryCommand(),
                "create_directory": MacOSCreateDirectoryCommand(),
                "remove_path": MacOSRemovePathCommand(),
                "copy_path": MacOSCopyPathCommand(),
                "base64_encode": MacOSBase64EncodeCommand(),
                "which": MacOSWhichCommand(),
                "pwd": MacOSPwdCommand(),
                "env_var": MacOSEnvVarCommand(),
                "find": MacOSFindCommand(),
            }
        

        OSCommandProvider

        Base class for OS-specific command providers using command classes.

        Source code in src/anyenv/os_commands/providers.py
        class OSCommandProvider:
            """Base class for OS-specific command providers using command classes."""
        
            def __init__(self) -> None:
                """Initialize the command provider with command instances."""
                self.commands: dict[
                    str,
                    ListDirectoryCommand
                    | FileInfoCommand
                    | ExistsCommand
                    | IsFileCommand
                    | IsDirectoryCommand
                    | CreateDirectoryCommand
                    | RemovePathCommand
                    | CopyPathCommand
                    | Base64EncodeCommand
                    | WhichCommand
                    | PwdCommand
                    | EnvVarCommand
                    | FindCommand,
                ] = {}
        
            @overload
            def get_command(self, command_type: Literal["list_directory"]) -> ListDirectoryCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["file_info"]) -> FileInfoCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["exists"]) -> ExistsCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["is_file"]) -> IsFileCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["is_directory"]) -> IsDirectoryCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["create_directory"]) -> CreateDirectoryCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["remove_path"]) -> RemovePathCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["copy_path"]) -> CopyPathCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["base64_encode"]) -> Base64EncodeCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["which"]) -> WhichCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["pwd"]) -> PwdCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["env_var"]) -> EnvVarCommand: ...
        
            @overload
            def get_command(self, command_type: Literal["find"]) -> FindCommand: ...
        
            def get_command(
                self, command_type: CommandType
            ) -> (
                ListDirectoryCommand
                | FileInfoCommand
                | ExistsCommand
                | IsFileCommand
                | IsDirectoryCommand
                | CreateDirectoryCommand
                | RemovePathCommand
                | CopyPathCommand
                | Base64EncodeCommand
                | WhichCommand
                | PwdCommand
                | EnvVarCommand
                | FindCommand
            ):
                """Get command instance by type."""
                return self.commands[command_type]
        

        __init__

        __init__() -> None
        

        Initialize the command provider with command instances.

        Source code in src/anyenv/os_commands/providers.py
        def __init__(self) -> None:
            """Initialize the command provider with command instances."""
            self.commands: dict[
                str,
                ListDirectoryCommand
                | FileInfoCommand
                | ExistsCommand
                | IsFileCommand
                | IsDirectoryCommand
                | CreateDirectoryCommand
                | RemovePathCommand
                | CopyPathCommand
                | Base64EncodeCommand
                | WhichCommand
                | PwdCommand
                | EnvVarCommand
                | FindCommand,
            ] = {}
        

        get_command

        get_command(command_type: Literal['list_directory']) -> ListDirectoryCommand
        
        get_command(command_type: Literal['file_info']) -> FileInfoCommand
        
        get_command(command_type: Literal['exists']) -> ExistsCommand
        
        get_command(command_type: Literal['is_file']) -> IsFileCommand
        
        get_command(command_type: Literal['is_directory']) -> IsDirectoryCommand
        
        get_command(command_type: Literal['create_directory']) -> CreateDirectoryCommand
        
        get_command(command_type: Literal['remove_path']) -> RemovePathCommand
        
        get_command(command_type: Literal['copy_path']) -> CopyPathCommand
        
        get_command(command_type: Literal['base64_encode']) -> Base64EncodeCommand
        
        get_command(command_type: Literal['which']) -> WhichCommand
        
        get_command(command_type: Literal['pwd']) -> PwdCommand
        
        get_command(command_type: Literal['env_var']) -> EnvVarCommand
        
        get_command(command_type: Literal['find']) -> FindCommand
        

        Get command instance by type.

        Source code in src/anyenv/os_commands/providers.py
        def get_command(
            self, command_type: CommandType
        ) -> (
            ListDirectoryCommand
            | FileInfoCommand
            | ExistsCommand
            | IsFileCommand
            | IsDirectoryCommand
            | CreateDirectoryCommand
            | RemovePathCommand
            | CopyPathCommand
            | Base64EncodeCommand
            | WhichCommand
            | PwdCommand
            | EnvVarCommand
            | FindCommand
        ):
            """Get command instance by type."""
            return self.commands[command_type]
        

        UnixCommandProvider

        Bases: OSCommandProvider

        Unix/Linux command provider using GNU/POSIX tools.

        Source code in src/anyenv/os_commands/providers.py
        class UnixCommandProvider(OSCommandProvider):
            """Unix/Linux command provider using GNU/POSIX tools."""
        
            def __init__(self) -> None:
                """Initialize Unix command provider with Unix command instances."""
                super().__init__()
                self.commands = {
                    "list_directory": UnixListDirectoryCommand(),
                    "file_info": UnixFileInfoCommand(),
                    "exists": UnixExistsCommand(),
                    "is_file": UnixIsFileCommand(),
                    "is_directory": UnixIsDirectoryCommand(),
                    "create_directory": UnixCreateDirectoryCommand(),
                    "remove_path": UnixRemovePathCommand(),
                    "copy_path": UnixCopyPathCommand(),
                    "base64_encode": UnixBase64EncodeCommand(),
                    "which": UnixWhichCommand(),
                    "pwd": UnixPwdCommand(),
                    "env_var": UnixEnvVarCommand(),
                    "find": UnixFindCommand(),
                }
        

        __init__

        __init__() -> None
        

        Initialize Unix command provider with Unix command instances.

        Source code in src/anyenv/os_commands/providers.py
        def __init__(self) -> None:
            """Initialize Unix command provider with Unix command instances."""
            super().__init__()
            self.commands = {
                "list_directory": UnixListDirectoryCommand(),
                "file_info": UnixFileInfoCommand(),
                "exists": UnixExistsCommand(),
                "is_file": UnixIsFileCommand(),
                "is_directory": UnixIsDirectoryCommand(),
                "create_directory": UnixCreateDirectoryCommand(),
                "remove_path": UnixRemovePathCommand(),
                "copy_path": UnixCopyPathCommand(),
                "base64_encode": UnixBase64EncodeCommand(),
                "which": UnixWhichCommand(),
                "pwd": UnixPwdCommand(),
                "env_var": UnixEnvVarCommand(),
                "find": UnixFindCommand(),
            }
        

        WindowsCommandProvider

        Bases: OSCommandProvider

        Windows command provider using PowerShell and CMD.

        Source code in src/anyenv/os_commands/providers.py
        class WindowsCommandProvider(OSCommandProvider):
            """Windows command provider using PowerShell and CMD."""
        
            def __init__(self) -> None:
                """Initialize Windows command provider with Windows command instances."""
                super().__init__()
                self.commands = {
                    "list_directory": WindowsListDirectoryCommand(),
                    "file_info": WindowsFileInfoCommand(),
                    "exists": WindowsExistsCommand(),
                    "is_file": WindowsIsFileCommand(),
                    "is_directory": WindowsIsDirectoryCommand(),
                    "create_directory": WindowsCreateDirectoryCommand(),
                    "remove_path": WindowsRemovePathCommand(),
                    "copy_path": WindowsCopyPathCommand(),
                    "base64_encode": WindowsBase64EncodeCommand(),
                    "which": WindowsWhichCommand(),
                    "pwd": WindowsPwdCommand(),
                    "env_var": WindowsEnvVarCommand(),
                    "find": WindowsFindCommand(),
                }
        

        __init__

        __init__() -> None
        

        Initialize Windows command provider with Windows command instances.

        Source code in src/anyenv/os_commands/providers.py
        def __init__(self) -> None:
            """Initialize Windows command provider with Windows command instances."""
            super().__init__()
            self.commands = {
                "list_directory": WindowsListDirectoryCommand(),
                "file_info": WindowsFileInfoCommand(),
                "exists": WindowsExistsCommand(),
                "is_file": WindowsIsFileCommand(),
                "is_directory": WindowsIsDirectoryCommand(),
                "create_directory": WindowsCreateDirectoryCommand(),
                "remove_path": WindowsRemovePathCommand(),
                "copy_path": WindowsCopyPathCommand(),
                "base64_encode": WindowsBase64EncodeCommand(),
                "which": WindowsWhichCommand(),
                "pwd": WindowsPwdCommand(),
                "env_var": WindowsEnvVarCommand(),
                "find": WindowsFindCommand(),
            }
        

        get_os_command_provider

        get_os_command_provider(
            system: Literal["Windows", "Darwin", "Linux"] | None = None,
        ) -> OSCommandProvider
        

        Auto-detect OS and return appropriate command provider.

        Parameters:

        Name Type Description Default
        system Literal['Windows', 'Darwin', 'Linux'] | None

        The system to use. If None, the current system is used.

        None

        Returns:

        Type Description
        OSCommandProvider

        OS-specific command provider based on current platform

        Source code in src/anyenv/os_commands/providers.py
        def get_os_command_provider(
            system: Literal["Windows", "Darwin", "Linux"] | None = None,
        ) -> OSCommandProvider:
            """Auto-detect OS and return appropriate command provider.
        
            Args:
                system: The system to use. If None, the current system is used.
        
            Returns:
                OS-specific command provider based on current platform
            """
            system_ = system or platform.system()
        
            if system_ == "Windows":
                return WindowsCommandProvider()
            if system_ == "Darwin":  # macOS
                return MacOSCommandProvider()
            # Linux and other Unix-like systems
            return UnixCommandProvider()