Skip to content

create_directory

Class info

Classes

Name Children Inherits
MacOSCreateDirectoryCommand
anyenv.os_commands.create_directory
macOS create directory command implementation.
    UnixCreateDirectoryCommand
    anyenv.os_commands.create_directory
    Unix/Linux create directory command implementation.
      WindowsCreateDirectoryCommand
      anyenv.os_commands.create_directory
      Windows create directory command implementation.

        🛈 DocStrings

        Create directory command implementations for different operating systems.

        MacOSCreateDirectoryCommand

        Bases: CreateDirectoryCommand

        macOS create directory command implementation.

        Source code in src/anyenv/os_commands/create_directory.py
        class MacOSCreateDirectoryCommand(CreateDirectoryCommand):
            """macOS create directory command implementation."""
        
            def create_command(self, path: str, parents: bool = True) -> str:
                """Generate mkdir command (same as Unix).
        
                Args:
                    path: Directory path to create
                    parents: Whether to create parent directories
        
                Returns:
                    The mkdir command string
                """
                return f"mkdir -p {sh_path(path)}" if parents else f"mkdir {sh_path(path)}"
        
            def parse_command(
                self,
                output: str,
                exit_code: int = 0,
            ) -> bool:
                """Parse mkdir result based on exit code (same as Unix).
        
                Args:
                    output: Raw command output (ignored)
                    exit_code: Command exit code
        
                Returns:
                    True if directory was created successfully, False otherwise
                """
                return exit_code == 0
        

        create_command

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

        Generate mkdir command (same as Unix).

        Parameters:

        Name Type Description Default
        path str

        Directory path to create

        required
        parents bool

        Whether to create parent directories

        True

        Returns:

        Type Description
        str

        The mkdir command string

        Source code in src/anyenv/os_commands/create_directory.py
        def create_command(self, path: str, parents: bool = True) -> str:
            """Generate mkdir command (same as Unix).
        
            Args:
                path: Directory path to create
                parents: Whether to create parent directories
        
            Returns:
                The mkdir command string
            """
            return f"mkdir -p {sh_path(path)}" if parents else f"mkdir {sh_path(path)}"
        

        parse_command

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

        Parse mkdir result based on exit code (same as Unix).

        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 directory was created successfully, False otherwise

        Source code in src/anyenv/os_commands/create_directory.py
        def parse_command(
            self,
            output: str,
            exit_code: int = 0,
        ) -> bool:
            """Parse mkdir result based on exit code (same as Unix).
        
            Args:
                output: Raw command output (ignored)
                exit_code: Command exit code
        
            Returns:
                True if directory was created successfully, False otherwise
            """
            return exit_code == 0
        

        UnixCreateDirectoryCommand

        Bases: CreateDirectoryCommand

        Unix/Linux create directory command implementation.

        Source code in src/anyenv/os_commands/create_directory.py
        class UnixCreateDirectoryCommand(CreateDirectoryCommand):
            """Unix/Linux create directory command implementation."""
        
            def create_command(self, path: str, parents: bool = True) -> str:
                """Generate Unix mkdir command.
        
                Args:
                    path: Directory path to create
                    parents: Whether to create parent directories
        
                Returns:
                    The mkdir command string
                """
                return f"mkdir -p {sh_path(path)}" if parents else f"mkdir {sh_path(path)}"
        
            def parse_command(
                self,
                output: str,
                exit_code: int = 0,
            ) -> bool:
                """Parse Unix mkdir result based on exit code.
        
                Args:
                    output: Raw command output (ignored)
                    exit_code: Command exit code
        
                Returns:
                    True if directory was created successfully, False otherwise
                """
                return exit_code == 0
        

        create_command

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

        Generate Unix mkdir command.

        Parameters:

        Name Type Description Default
        path str

        Directory path to create

        required
        parents bool

        Whether to create parent directories

        True

        Returns:

        Type Description
        str

        The mkdir command string

        Source code in src/anyenv/os_commands/create_directory.py
        def create_command(self, path: str, parents: bool = True) -> str:
            """Generate Unix mkdir command.
        
            Args:
                path: Directory path to create
                parents: Whether to create parent directories
        
            Returns:
                The mkdir command string
            """
            return f"mkdir -p {sh_path(path)}" if parents else f"mkdir {sh_path(path)}"
        

        parse_command

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

        Parse Unix mkdir 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 directory was created successfully, False otherwise

        Source code in src/anyenv/os_commands/create_directory.py
        def parse_command(
            self,
            output: str,
            exit_code: int = 0,
        ) -> bool:
            """Parse Unix mkdir result based on exit code.
        
            Args:
                output: Raw command output (ignored)
                exit_code: Command exit code
        
            Returns:
                True if directory was created successfully, False otherwise
            """
            return exit_code == 0
        

        WindowsCreateDirectoryCommand

        Bases: CreateDirectoryCommand

        Windows create directory command implementation.

        Source code in src/anyenv/os_commands/create_directory.py
        class WindowsCreateDirectoryCommand(CreateDirectoryCommand):
            """Windows create directory command implementation."""
        
            def create_command(self, path: str, parents: bool = True) -> str:
                """Generate Windows directory creation command.
        
                Args:
                    path: Directory path to create
                    parents: Whether to create parent directories
        
                Returns:
                    The directory creation command string
                """
                script = f"New-Item -ItemType Directory -Path {ps_literal(path)}"
                return powershell(f"{script} -Force" if parents else script)
        
            def parse_command(
                self,
                output: str,
                exit_code: int = 0,
            ) -> bool:
                """Parse Windows directory creation result.
        
                Args:
                    output: Raw command output (ignored)
                    exit_code: Command exit code
        
                Returns:
                    True if directory was created successfully, False otherwise
                """
                return exit_code == 0
        

        create_command

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

        Generate Windows directory creation command.

        Parameters:

        Name Type Description Default
        path str

        Directory path to create

        required
        parents bool

        Whether to create parent directories

        True

        Returns:

        Type Description
        str

        The directory creation command string

        Source code in src/anyenv/os_commands/create_directory.py
        def create_command(self, path: str, parents: bool = True) -> str:
            """Generate Windows directory creation command.
        
            Args:
                path: Directory path to create
                parents: Whether to create parent directories
        
            Returns:
                The directory creation command string
            """
            script = f"New-Item -ItemType Directory -Path {ps_literal(path)}"
            return powershell(f"{script} -Force" if parents else script)
        

        parse_command

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

        Parse Windows directory creation result.

        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 directory was created successfully, False otherwise

        Source code in src/anyenv/os_commands/create_directory.py
        def parse_command(
            self,
            output: str,
            exit_code: int = 0,
        ) -> bool:
            """Parse Windows directory creation result.
        
            Args:
                output: Raw command output (ignored)
                exit_code: Command exit code
        
            Returns:
                True if directory was created successfully, False otherwise
            """
            return exit_code == 0