mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-18 00:45:47 +00:00
By default Miller does not infer booleans from data files: "true" and "false" (let alone "True", "yes", "on", etc.) are read as strings. This adds opt-in flags letting users specify exactly which field values should be inferred as boolean true/false when read from data files: mlr --infer-true True,yes,on --infer-false False,no,off ... Details: * Matching is exact and case-sensitive; unlisted values are unaffected. * As with ints and floats, the original string representation is retained for non-JSON output, so CSV/TSV/etc. round-trip unchanged. * JSON output emits canonical true/false (fixed marshalJSONBool to use the underlying boolean rather than the retained string, which would otherwise produce invalid JSON for e.g. "yes"). * Works with the -O and -A inference variants; -S (no inference) bypasses it, as it bypasses all other type inference. * Works from .mlrrc as infer-true/infer-false, like any other flag. Includes unit tests, regression-test cases under test/cases/io-infer-flags/, and doc updates (reference-main-data-types, regenerated flag list and man pages). Addresses #1651. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| doc.go | ||
| errors.go | ||
| flag_json.go | ||
| flag_types.go | ||
| flag_types_test.go | ||
| flatten_unflatten.go | ||
| mlrcli_util.go | ||
| option_parse.go | ||
| option_types.go | ||
| README.md | ||
| separators.go | ||
| verb_utils.go | ||
Datatypes for parsing the Miller command line, and the flags table.
pkg/climainis the flag-parsing logic for supporting Miller's command-line interface. When you type something likemlr --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 ofputthenfilter, and a JSON record-writer.pkg/clicontains datatypes and the flags table for the CLI-parser, which was split out to avoid a Go package-import cycle.