Skip to content

MacOSPwdCommand

Base classes

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

⋔ Inheritance diagram

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

🛈 DocStrings

Bases: PwdCommand

macOS pwd command implementation.

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

    def create_command(self) -> str:
        """Generate pwd command (same as Unix).

        Returns:
            The pwd command string
        """
        return "pwd"

    def parse_command(self, output: str, exit_code: int = 0) -> str | None:
        """Parse pwd result (same as Unix).

        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 pwd command (same as Unix).

Returns:

Type Description
str

The pwd command string

Source code in src/anyenv/os_commands/pwd.py
def create_command(self) -> str:
    """Generate pwd command (same as Unix).

    Returns:
        The pwd command string
    """
    return "pwd"

parse_command

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

Parse pwd result (same as Unix).

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 pwd result (same as Unix).

    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