module
Noir::CLI::Legacy
Overview
Translates v0.x terminal flags into v1 subcommand invocations.
In v0 these flags would parse, print something, and exit: --list-techs -> noir list techs --list-taggers -> noir list taggers --build-info -> noir version --verbose --generate-completion S -> noir completion S --help-all -> noir help
Non-terminal v0 flags (-b, -P, --ai-context, ...) stay in ARGV.
The router sends them to the default scan subcommand, which parses
them via its own OptionParser. That keeps noir -b ./app -P working
exactly as it did in v0.
Defined in:
cli/legacy.crConstant Summary
-
LEGACY_FLAG_ALIASES =
{"--send-req" => "--probe", "--send-proxy" => "--probe-via", "--send-es" => "--export-es", "--with-headers" => "--probe-header", "--use-matchers" => "--probe-match", "--use-filters" => "--probe-skip"} -
v0 deliver/probe flag tokens, translated to their v1 equivalents before the scan OptionParser sees ARGV. Doing the swap here keeps the LEGACY block out of
scan -h(and out of tab-completion) entirely — there's no shadowparser.onfor each old flag name — while existing CI scripts and v0 Dockerfile entrypoints keep parsing without modification. Mirrors the YAML-side migration inConfigInitializer::LEGACY_CONFIG_KEY_MAP. -
TERMINAL_REWRITES =
{"--list-techs" => ["list", "techs"], "--list-taggers" => ["list", "taggers"], "--build-info" => ["version", "--verbose"], "--help-all" => ["help"], "-v" => ["version"], "-V" => ["version"], "--version" => ["version"]} -
Global short-circuits for v0-shaped invocations. v0 had no verb, so these flags could sit anywhere in ARGV; the first one found rewrites the whole invocation to the canonical v1 subcommand call. A v1 invocation that opens with a verb is exempt — see
.rewrite.
Class Method Summary
-
.rewrite(argv : Array(String)) : Array(String)
Returns a possibly-rewritten ARGV.
-
.subcommand_invocation?(argv : Array(String)) : Bool
True when ARGV opens with a v1 verb, i.e.
-
.translate_flag_aliases(argv : Array(String)) : Array(String)
Walks ARGV and rewrites any v0 deliver/probe flag token to its v1 equivalent.
Class Method Detail
Returns a possibly-rewritten ARGV. If a terminal v0 flag is found, the entire ARGV is replaced with the equivalent v1 invocation.
The scan stops before it starts on a v1 subcommand invocation. The
rewrite table is a global argv substitution, so scanning past a
verb let it hijack that subcommand's own flags: noir rules update -v matched -v => ["version"], printed the version and exited 0
while noir rules --help advertises -v, --verbose and the rules
were never updated — silently turning the documented
noir rules update && noir scan . -P precondition into a no-op that
reports success. -V, --version, --list-techs, --build-info,
--help-all and --generate-completion had the identical exposure,
so the rule itself is scoped rather than the one entry. v0
invocations are unaffected: they have no verb to open with (v0 had
no subcommands), so noir -b ./app --list-techs still rewrites.
True when ARGV opens with a v1 verb, i.e. exactly the shape the
router dispatches to a subcommand (head must be in
KNOWN_COMMANDS). Everything after that verb is that subcommand's
own argv and must reach its own parser untouched.
Walks ARGV and rewrites any v0 deliver/probe flag token to its v1
equivalent. Handles both the bare form (--send-proxy URL) and
the = form (--send-proxy=URL) so neither shape leaks the v0
name into the OptionParser. Unknown tokens pass through
unchanged — this method intentionally narrow.