miller/pkg/cli
John Kerl 75275fdcbe
Add named profile sections to .mlrrc, selected via --profile / -P (#358) (#2191)
* Add named profile sections to .mlrrc, selected via --profile / -P (#358)

.mlrrc files may now contain INI-style named sections ("profiles"):

  # Global settings, applied always:
  icsv

  [j]
  ojson
  jvstack

  [tsvout]
  otsv

Lines before any section header are global settings, applied always, so
existing .mlrrc files behave exactly as before. The new main flag
--profile {name} (alias -P {name}) applies the settings from the [name]
section after the global settings; without it, sections are ignored
entirely (their lines aren't even parsed).

It's a fatal error if a requested profile has no matching section in any
.mlrrc file processed, if no .mlrrc file was found at all, or if
--profile is combined with --norc or MLRRC=__none__.

Also fixes the regression-tester to restore per-case environment
variables to their prior values after each case, rather than setting
them to the empty string -- needed so cases pointing MLRRC at a test
file don't clobber the suite-wide MLRRC=__none__ guard.

Includes unit tests, regression-test cases, and doc/man-page updates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Reject --profile / -P within .mlrrc files (#358)

Per maintainer feedback on the PR: profiles are selected on the mlr
command line, not from within a .mlrrc file, so --profile / -P inside a
.mlrrc file is now a parse error -- the same way --prepipe is rejected
there -- rather than being silently ignored.

Adds a unit test, a should-fail regression case, and a docs bullet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 16:49:15 -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 named profile sections to .mlrrc, selected via --profile / -P (#358) (#2191) 2026-07-14 16:49:15 -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.