result¶
Unified result family for host verbs.
Every @cli_exposed host verb returns a member of this family (except
interact(), which returns None): scalar verbs return Result
or CommandResult; run() returns Results. The CLI derives
its exit code from Result.exit_code.
>>> from otto.utils import Status
>>> r = Result(Status.Success, value=["mod_a"], msg="")
>>> r.is_ok, r.exit_code
(True, 0)
>>> cr = CommandResult(Status.Failed, value="", command="false", retcode=1)
>>> cr.exit_code
1
>>> res = Results.collect([cr])
>>> res.only.command, res.exit_code, bool(res)
('false', 1, False)
-
class otto.result.Result(status: Status, value: Any | None =
None, msg: str ='')¶ Bases:
objectOutcome of a host verb: status + optional payload + human diagnostic.
-
class otto.result.CommandResult(status: Status, value: Any | None =
None, msg: str ='', command: str ='', retcode: int =-1)¶ Bases:
ResultResult of one shell command;
valueholds the command’s output.
-
class otto.result.ShellResult(status: Status, value: Any | None =
None, msg: str ='', command: str ='', output: str ='')¶ Bases:
ResultResult of one
AppShellcommand.valueholds the parsed object (or the raw output when no parser was given);outputalways keeps the raw, prompt-stripped text for debugging.
-
class otto.result.Results(status: Status, value: Any | None =
None, msg: str ='')¶ Bases:
Result,Sequence[CommandResult]Aggregate over per-command results; itself a
Result.Returned by
run()only.valueislist[CommandResult]in execution order. Build withcollect(), which computes the aggregate status:Successwhen every entry is ok, otherwise the first non-ok entry’s status. Truthiness followsis_ok, not emptiness.-
classmethod collect(items: Sequence[CommandResult], msg: str =
'') Results¶ Build a Results from per-command entries, computing the aggregate.
- property only : CommandResult¶
The sole entry when exactly one command ran; ValueError otherwise.
- property first_failure : CommandResult | None¶
The first non-ok entry, or None when everything passed.
-
classmethod collect(items: Sequence[CommandResult], msg: str =