API CLI Helpers #
Small command-line parsers shared by examples, verification tools, and public facade helpers.
This module stays independent of tensors and runtime modules so lightweight artifact checkers can reuse the CLI surface without importing the full public API.
Lift a shared CLI parser result into IO.userError.
Instances For
Parse an optional string-valued flag and fall back to a provided default.
Use this when a command parser wants a concrete string immediately rather than an optional override.
Instances For
Look up a string-valued flag without returning the remaining arguments.
This is useful for command shapes that support optional overrides but do not otherwise need a
left-to-right consuming parser. Accepted forms are the same as takeFlagValueOnce:
--key value and --key=value.
Instances For
Parse an optional string-valued flag, fall back to a provided default spelling when absent, and decode the selected spelling with a caller-supplied parser.
This is useful for enum-like CLI flags whose valid strings remain command-specific.
Instances For
Remove every occurrence of a string-valued flag, accepting both --key value and --key=value.
This is for wrapper commands that own a flag locally and forward the remaining arguments to another tool. It deliberately does not reject duplicates; the wrapper's local parser decides whether a duplicated flag is an error.
Instances For
Return true when the argument list requests command help.
Instances For
Take at most one positional argument, leaving flags untouched.
This is useful for commands with a single optional artifact path plus named flags. A second positional argument is reported as an error instead of being silently ignored.
Instances For
Normalize commands that accept either a positional path or a named path flag.
If --key / --key=... is already present, the argument list is returned unchanged. Otherwise the
first positional argument is rewritten to --key=<path>. If there is no positional path, the
provided default path is inserted.
Instances For
Parse one ASCII decimal digit.
Instances For
Parse a nonempty string of ASCII decimal digits.
Instances For
Parse a CLI boolean value. Accepted spellings are true, false, 1, and 0.
Instances For
Remove a boolean flag that may be written either as a bare switch or with an explicit value.
Accepted forms:
--key--key=true--key=false--key true--key false
When --key is followed by a non-boolean token, the flag is treated as a bare switch and the next
token is left for the caller. Duplicate occurrences are rejected.
Instances For
Like takeFlagValueOnce, but return the value as a System.FilePath.
Instances For
Parse an optional path flag and fall back to the provided default path.
Use this when an example parser wants a concrete path immediately instead of an optional override.
Instances For
Parse two optional path flags that must appear together if either one is present.
This is useful for paired artifacts such as tokenizer vocab/merge files, where a single path is not meaningful on its own.
Instances For
Common training flags for epoch-oriented loader/tutorial commands: --epochs and --batch.
Instances For
Parse optional --epochs and --batch flags for the epoch-oriented tutorial helpers.
Returns the parsed values (falling back to the provided defaults) and the remaining args.
Instances For
Parse optional --epochs and --batch flags for the epoch-oriented tutorial helpers, fall back to
the provided defaults, and require that both selected values are strictly positive.