Skip to content

WindowsCreateDirectoryCommand

Base classes

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

⋔ Inheritance diagram

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

🛈 DocStrings

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

:fa-brands-github: Show source on GitHub