miller/pkg/cli
John Kerl 28e28df46f Add opt-in --infer-booleans and --infer-special-floats type-inference flags (#965)
By default, Miller treats "true"/"false" and IEEE special floats like
"Inf", "Infinity", and "NaN" in data files as strings. This adds two
opt-in flags, following the existing -S/-A/-O inference-flag family:

* --infer-booleans: treat "true" and "false" (exactly those spellings,
  matching the DSL's and JSON's boolean literals) as booleans.
* --infer-special-floats: treat "Inf", "Infinity", and "NaN" --
  case-insensitively, with optional leading +/- on the first two -- as
  floats.

Unlike -S/-A/-O, these don't replace the package-level inferrer; they
augment it, so they compose with -A and -O. They intentionally have no
effect with -S/--infer-none, which disables type inference entirely.
Default behavior is unchanged.

Includes unit tests, regression-test cases under
test/cases/io-infer-flags/, and documentation updates.

Addresses #965.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 09:43:58 -04:00
..
doc.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
errors.go Improve error propagation (#1975) 2026-02-16 16:48:41 -05:00
flag_json.go Switch to --as-json (#2106) 2026-06-28 17:04:10 -04:00
flag_types.go Shell tab-completion for bash and zsh (#2096) 2026-06-21 12:47:54 -04:00
flag_types_test.go Shell tab-completion for bash and zsh (#2096) 2026-06-21 12:47:54 -04:00
flatten_unflatten.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
mlrcli_util.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
option_parse.go Add opt-in --infer-booleans and --infer-special-floats type-inference flags (#965) 2026-07-14 09:43:58 -04:00
option_types.go Exit 0 when skip-trivial-records is used and CSV/TSV ends with blank lines (#1535) (#2146) 2026-07-06 15:22:51 -04:00
README.md Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
separators.go Shell tab-completion for bash and zsh (#2096) 2026-06-21 12:47:54 -04:00
verb_utils.go Improve error propagation (#1975) 2026-02-16 16:48:41 -05:00

Datatypes for parsing the Miller command line, and the flags table.

  • pkg/climain is the flag-parsing logic for supporting Miller's command-line interface. When you type something like mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer chain of put then filter, and a JSON record-writer.
  • pkg/cli contains datatypes and the flags table for the CLI-parser, which was split out to avoid a Go package-import cycle.