class

Hwaro::CLI::Runner

Inherits Reference < Object

Constructors

Class methods

apply_global_quiet!(argv : Array(String))

Strip --quiet / -q from argv and enable Logger.quiet when present. Mutates the given array in place so subsequent parsers don't see it. Arguments after -- are positionals and are left alone.

Source
emit_hwaro_error(err : Hwaro::HwaroError, io : IO = STDERR)

Emit a classified error in either the quiet/JSON machine shape or the human-friendly Error [CODE]: message form. JSON mode is detected from Runner.json_mode? (set by commands that saw --json) or from the raw ARGV (unknown-command path, before any parser runs).

Source
enable_json_mode!

Enable JSON output mode: silence human log lines and flag json_mode so error/output payloads emit machine JSON. Call when a command parses --json.

Source
exit_with_error_payload(err : Hwaro::HwaroError) : NoReturn

--json failure exit: print the classified error payload on stdout and exit with the error's own code. Every command that handles --json itself funnels its HwaroError rescues through here so the envelope cannot drift between commands.

Source
flag_args(argv : Array(String)) : Array(String)

The arguments that can be flags: everything before a -- separator. Raw-argv scans for global flags must stop there, or hwaro init -- -q (a directory named -q) loses its only positional and falls back to . — with --clean, emptying the current directory.

Source
json_flag?(argv : Array(String)) : Bool

--json or its documented short form -j, before any --. The raw-argv check for errors raised before a command's parser ran.

Source
json_mode=(value : Bool)
Source
json_mode?
Source
unknown_command!(command : String, args : Array(String)) : NoReturn

Classified usage error for an unknown top-level command, shared by hwaro <command> and hwaro help <command>. The "Did you mean …" suggestion prints to stderr (text mode only) so the final error line emitted by run's rescue is the Error [CODE]: … form.

Source

Instance methods