Skip to content

CommandResult

🛈 DocStrings

Result from command execution.

This represents the output of a command that can be piped to another command. Separate from ctx.print() which is for user-facing status messages.

Attributes:

Name Type Description
stdout str

Standard output (data that can be piped)

stderr str

Standard error (error messages)

exit_code int

Exit code (0 = success, non-zero = failure)

Source code in src/slashed/base.py
@dataclass
class CommandResult:
    """Result from command execution.

    This represents the output of a command that can be piped to another command.
    Separate from ctx.print() which is for user-facing status messages.

    Attributes:
        stdout: Standard output (data that can be piped)
        stderr: Standard error (error messages)
        exit_code: Exit code (0 = success, non-zero = failure)
    """

    stdout: str = ""
    stderr: str = ""
    exit_code: int = 0

    def __bool__(self) -> bool:
        """Return True if command succeeded (exit_code == 0)."""
        return self.exit_code == 0

__bool__

__bool__() -> bool

Return True if command succeeded (exit_code == 0).

Source code in src/slashed/base.py
def __bool__(self) -> bool:
    """Return True if command succeeded (exit_code == 0)."""
    return self.exit_code == 0

:fa-brands-github: Show source on GitHub