Skip to content

WindowsPwdCommand

Base classes

Name Children Inherits
PwdCommand
anyenv.os_commands.base
Base class for pwd (print working directory) commands.

⋔ Inheritance diagram

graph TD
  988690578["pwd.WindowsPwdCommand"]
  2510224188["base.PwdCommand"]
  925645236["abc.ABC"]
  2751680898["builtins.object"]
  2510224188 --> 988690578
  925645236 --> 2510224188
  2751680898 --> 925645236

🛈 DocStrings

Bases: PwdCommand

Windows pwd command implementation.

Source code in src/anyenv/os_commands/pwd.py
class WindowsPwdCommand(PwdCommand):
    """Windows pwd command implementation."""

    def create_command(self) -> str:
        """Generate Windows cd command (prints current directory when no args).

        Returns:
            The cd command string
        """
        return "cd"

    def parse_command(self, output: str, exit_code: int = 0) -> str | None:
        """Parse Windows cd result.

        Args:
            output: Raw command output
            exit_code: Command exit code

        Returns:
            Current working directory or None on failure
        """
        if exit_code != 0:
            return None
        path = output.strip()
        return path if path else None

create_command

create_command() -> str

Generate Windows cd command (prints current directory when no args).

Returns:

Type Description
str

The cd command string

Source code in src/anyenv/os_commands/pwd.py
def create_command(self) -> str:
    """Generate Windows cd command (prints current directory when no args).

    Returns:
        The cd command string
    """
    return "cd"

parse_command

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

Parse Windows cd result.

Parameters:

Name Type Description Default
output str

Raw command output

required
exit_code int

Command exit code

0

Returns:

Type Description
str | None

Current working directory or None on failure

Source code in src/anyenv/os_commands/pwd.py
def parse_command(self, output: str, exit_code: int = 0) -> str | None:
    """Parse Windows cd result.

    Args:
        output: Raw command output
        exit_code: Command exit code

    Returns:
        Current working directory or None on failure
    """
    if exit_code != 0:
        return None
    path = output.strip()
    return path if path else None

:fa-brands-github: Show source on GitHub