class

Jargon::Result

Inherits Reference < Object

Outcome of parsing arguments. Carries the parsed data, any validation errors, and the resolved subcommand, plus flags describing meta-requests (help, shell completion) that run acts on automatically. A pending help/completion request is not a validation outcome — check help_requested?/completion_requested? before treating errors as final.

Constructors

new(data : JSON::Any, errors : Array(String) = [] of String, subcommand : String | Nil = nil, help_requested : Bool = false, help_subcommand : String | Nil = nil, completion_shell : String | Nil = nil)
Source
new(data : Hash(String, JSON::Any), errors : Array(String) = [] of String, subcommand : String | Nil = nil, help_requested : Bool = false, help_subcommand : String | Nil = nil, completion_shell : String | Nil = nil)
Source

Instance methods

[](key : String) : JSON::Any

Fetch a top-level value, raising KeyError if absent.

Source
[]?(key : String) : JSON::Any | Nil

Fetch a top-level value, or nil if absent.

Source
completion_requested?

True when --completions <shell> was requested.

Source
completion_shell

The shell passed to --completions (e.g. "bash"), or nil if not requested.

Source
data
Source
errors
Source
help?

Alias for help_requested?.

Source
help_requested?
Source
help_subcommand

Which subcommand's help was requested (nil = top-level help).

Source
subcommand

Resolved subcommand name, space-separated for nested commands; nil for a flat CLI or when no subcommand matched.

Source
to_json

The parsed data as a compact JSON string.

Source
to_pretty_json

The parsed data as an indented JSON string.

Source
valid?

True when parsing produced no validation errors. Note a help/completion request is also error-free, so guard those separately when it matters.

Source