Skip to content

UnixCreateDirectoryCommand

Base classes

Name Children Inherits
CreateDirectoryCommand
anyenv.os_commands.base
Base class for create directory commands.

⋔ Inheritance diagram

graph TD
  1250196185["create_directory.UnixCreateDirectoryCommand"]
  2491271628["base.CreateDirectoryCommand"]
  925645236["abc.ABC"]
  2751680898["builtins.object"]
  2491271628 --> 1250196185
  925645236 --> 2491271628
  2751680898 --> 925645236

🛈 DocStrings

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

:fa-brands-github: Show source on GitHub