class
Jargon::Result
- Jargon::Result
- Reference
- Object
Overview
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.
Defined in:
jargon/result.crConstructors
- .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)
- .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)
Instance Method Summary
-
#[](key : String) : JSON::Any
Fetch a top-level value, raising
KeyErrorif absent. -
#[]?(key : String) : JSON::Any | Nil
Fetch a top-level value, or nil if absent.
-
#completion_requested? : Bool
True when
--completions <shell>was requested. -
#completion_shell : String | Nil
The shell passed to
--completions(e.g. - #data : JSON::Any
- #errors : Array(String)
-
#help? : Bool
Alias for
#help_requested?. - #help_requested? : Bool
-
#help_subcommand : String | Nil
Which subcommand's help was requested (nil = top-level help).
-
#subcommand : String | Nil
Resolved subcommand name, space-separated for nested commands; nil for a flat CLI or when no subcommand matched.
-
#to_json : String
The parsed data as a compact JSON string.
-
#to_pretty_json : String
The parsed data as an indented JSON string.
-
#valid? : Bool
True when parsing produced no validation errors.
Constructor Detail
Instance Method Detail
The shell passed to --completions (e.g. "bash"), or nil if not requested.
Resolved subcommand name, space-separated for nested commands; nil for a flat CLI or when no subcommand matched.
True when parsing produced no validation errors. Note a help/completion request is also error-free, so guard those separately when it matters.