miller/go/src/cli
John Kerl 7909073b93 Merge pull request #435 from johnkerl/verb-fraction
Port fraction verb from C to Go
2021-03-01 00:13:29 -05:00
..
mlrcli.go go.mod attempt 2021-02-14 01:13:24 -05:00
mlrcli_parse.go go.mod attempt 2021-02-14 01:13:24 -05:00
mlrcli_transformers.go Merge pull request #435 from johnkerl/verb-fraction 2021-03-01 00:13:29 -05:00
mlrcli_usage.go go.mod attempt 2021-02-14 01:13:24 -05:00
README.md more of same 2021-02-14 01:25:32 -05:00

Logic for parsing the Miller command line.

  • src/cli 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.
  • src/cliutil contains datatypes for the CLI-parser, which was split out to avoid a Go package-import cycle.
  • I don't use the Go flag package here, although I do use it within the transformers' subcommand flag-handling. The flag package is quite fine; Miller's command-line processing is multi-purpose between serving CLI needs per se as well as for manpage/docfile generation, and I found it simplest to roll my own command-line handling here.