Skip to content

OSCommandProvider

Sub classes

Name Children Inherits
UnixCommandProvider
anyenv.os_commands.providers
Unix/Linux command provider using GNU/POSIX tools.
    MacOSCommandProvider
    anyenv.os_commands.providers
    macOS command provider using BSD tools.
      WindowsCommandProvider
      anyenv.os_commands.providers
      Windows command provider using PowerShell and CMD.

        🛈 DocStrings

        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]
        

        :fa-brands-github: Show source on GitHub