Skip to content

FindCommand

Sub classes

Name Children Inherits
UnixFindCommand
anyenv.os_commands.find
Unix/Linux find command implementation.
    MacOSFindCommand
    anyenv.os_commands.find
    macOS find command implementation (BSD find).
      WindowsFindCommand
      anyenv.os_commands.find
      Windows find command implementation using PowerShell.

        Base classes

        Name Children Inherits
        ABC
        abc
        Helper class that provides a standard way to create an ABC using

        ⋔ Inheritance diagram

        graph TD
          1345197150["base.FindCommand"]
          925645236["abc.ABC"]
          2751680898["builtins.object"]
          925645236 --> 1345197150
          2751680898 --> 925645236

        🛈 DocStrings

        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
            """
        

        :fa-brands-github: Show source on GitHub