From 44a2e4dc48b8ffd30af937bca7182eac83836041 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 9 Jan 2022 00:04:30 -0500 Subject: [PATCH] Make --jlistwrap / --jvstack as legacy flags, since now --json and --jsonl --- docs/src/manpage.md | 18 +++--- docs/src/manpage.txt | 18 +++--- docs/src/online-help.md | 1 - docs/src/reference-main-flag-list.md | 15 ++--- internal/pkg/cli/option_parse.go | 82 +++++++++++++--------------- man/manpage.txt | 18 +++--- man/mlr.1 | 26 +++------ todo.txt | 1 + 8 files changed, 78 insertions(+), 101 deletions(-) diff --git a/docs/src/manpage.md b/docs/src/manpage.md index 8a9170dbd..7bfa59621 100644 --- a/docs/src/manpage.md +++ b/docs/src/manpage.md @@ -149,7 +149,6 @@ HELP OPTIONS mlr help file-format-flags mlr help flatten-unflatten-flags mlr help format-conversion-keystroke-saver-flags - mlr help json-only-flags mlr help legacy-flags mlr help miscellaneous-flags mlr help output-colorization-flags @@ -436,20 +435,14 @@ FORMAT-CONVERSION KEYSTROKE-SAVER FLAGS -p Keystroke-saver for `--nidx --fs space --repifs`. -T Keystroke-saver for `--nidx --fs tab`. -JSON-ONLY FLAGS - These are flags which are applicable to JSON format. - - --jlistwrap or --jl Wrap JSON output in outermost `[ ]`. - --jvstack Put one key-value pair per line for JSON output - (multi-line output). - --no-jvstack Put objects/arrays all on one line for JSON output. - LEGACY FLAGS These are flags which don't do anything in the current Miller version. They are accepted as no-op flags in order to keep old scripts from breaking. --jknquoteint Type information from JSON input files is now preserved throughout the processing stream. + --jlistwrap or --jl Wrap JSON output in outermost `[ ]`. This is the + default for JSON output format. --jquoteall Type information from JSON input files is now preserved throughout the processing stream. --json-fatal-arrays-on-input @@ -461,8 +454,15 @@ LEGACY FLAGS --jsonx The `--jvstack` flag is now default true in Miller 6. --jvquoteall Type information from JSON input files is now preserved throughout the processing stream. + --jvstack Put one key-value pair per line for JSON output + (multi-line output). This is the default for JSON + output format. --mmap Miller no longer uses memory-mapping to access data files. + --no-jlistwrap Wrap JSON output in outermost `[ ]`. This is the + default for JSON Lines output format. + --no-jvstack Put objects/arrays all on one line for JSON output. + This is the default for JSON Lines output format. --no-mmap Miller no longer uses memory-mapping to access data files. --ojsonx The `--jvstack` flag is now default true in Miller 6. diff --git a/docs/src/manpage.txt b/docs/src/manpage.txt index 0c56b04eb..1a0c858b7 100644 --- a/docs/src/manpage.txt +++ b/docs/src/manpage.txt @@ -128,7 +128,6 @@ HELP OPTIONS mlr help file-format-flags mlr help flatten-unflatten-flags mlr help format-conversion-keystroke-saver-flags - mlr help json-only-flags mlr help legacy-flags mlr help miscellaneous-flags mlr help output-colorization-flags @@ -415,20 +414,14 @@ FORMAT-CONVERSION KEYSTROKE-SAVER FLAGS -p Keystroke-saver for `--nidx --fs space --repifs`. -T Keystroke-saver for `--nidx --fs tab`. -JSON-ONLY FLAGS - These are flags which are applicable to JSON format. - - --jlistwrap or --jl Wrap JSON output in outermost `[ ]`. - --jvstack Put one key-value pair per line for JSON output - (multi-line output). - --no-jvstack Put objects/arrays all on one line for JSON output. - LEGACY FLAGS These are flags which don't do anything in the current Miller version. They are accepted as no-op flags in order to keep old scripts from breaking. --jknquoteint Type information from JSON input files is now preserved throughout the processing stream. + --jlistwrap or --jl Wrap JSON output in outermost `[ ]`. This is the + default for JSON output format. --jquoteall Type information from JSON input files is now preserved throughout the processing stream. --json-fatal-arrays-on-input @@ -440,8 +433,15 @@ LEGACY FLAGS --jsonx The `--jvstack` flag is now default true in Miller 6. --jvquoteall Type information from JSON input files is now preserved throughout the processing stream. + --jvstack Put one key-value pair per line for JSON output + (multi-line output). This is the default for JSON + output format. --mmap Miller no longer uses memory-mapping to access data files. + --no-jlistwrap Wrap JSON output in outermost `[ ]`. This is the + default for JSON Lines output format. + --no-jvstack Put objects/arrays all on one line for JSON output. + This is the default for JSON Lines output format. --no-mmap Miller no longer uses memory-mapping to access data files. --ojsonx The `--jvstack` flag is now default true in Miller 6. diff --git a/docs/src/online-help.md b/docs/src/online-help.md index 0216e0cda..0b6d9a674 100644 --- a/docs/src/online-help.md +++ b/docs/src/online-help.md @@ -57,7 +57,6 @@ Flags: mlr help file-format-flags mlr help flatten-unflatten-flags mlr help format-conversion-keystroke-saver-flags - mlr help json-only-flags mlr help legacy-flags mlr help miscellaneous-flags mlr help output-colorization-flags diff --git a/docs/src/reference-main-flag-list.md b/docs/src/reference-main-flag-list.md index b3f06fdc2..710d48809 100644 --- a/docs/src/reference-main-flag-list.md +++ b/docs/src/reference-main-flag-list.md @@ -218,17 +218,6 @@ Additionally: * `-p` is a keystroke-saver for `--nidx --fs space --repifs`. * `-T` is a keystroke-saver for `--nidx --fs tab`. -## JSON-only flags - -These are flags which are applicable to JSON format. - - -**Flags:** - -* `--jlistwrap or --jl`: Wrap JSON output in outermost `[ ]`. -* `--jvstack`: Put one key-value pair per line for JSON output (multi-line output). -* `--no-jvstack`: Put objects/arrays all on one line for JSON output. - ## Legacy flags These are flags which don't do anything in the current Miller version. @@ -238,13 +227,17 @@ They are accepted as no-op flags in order to keep old scripts from breaking. **Flags:** * `--jknquoteint`: Type information from JSON input files is now preserved throughout the processing stream. +* `--jlistwrap or --jl`: Wrap JSON output in outermost `[ ]`. This is the default for JSON output format. * `--jquoteall`: Type information from JSON input files is now preserved throughout the processing stream. * `--json-fatal-arrays-on-input`: Miller now supports arrays as of version 6. * `--json-map-arrays-on-input`: Miller now supports arrays as of version 6. * `--json-skip-arrays-on-input`: Miller now supports arrays as of version 6. * `--jsonx`: The `--jvstack` flag is now default true in Miller 6. * `--jvquoteall`: Type information from JSON input files is now preserved throughout the processing stream. +* `--jvstack`: Put one key-value pair per line for JSON output (multi-line output). This is the default for JSON output format. * `--mmap`: Miller no longer uses memory-mapping to access data files. +* `--no-jlistwrap`: Wrap JSON output in outermost `[ ]`. This is the default for JSON Lines output format. +* `--no-jvstack`: Put objects/arrays all on one line for JSON output. This is the default for JSON Lines output format. * `--no-mmap`: Miller no longer uses memory-mapping to access data files. * `--ojsonx`: The `--jvstack` flag is now default true in Miller 6. * `--quote-all`: Ignored as of version 6. Types are inferred/retained through the processing flow now. diff --git a/internal/pkg/cli/option_parse.go b/internal/pkg/cli/option_parse.go index de9fbcf9d..77140304c 100644 --- a/internal/pkg/cli/option_parse.go +++ b/internal/pkg/cli/option_parse.go @@ -91,7 +91,6 @@ var FLAG_TABLE = FlagTable{ &SeparatorFlagSection, &FileFormatFlagSection, &FormatConversionKeystrokeSaverFlagSection, - &JSONOnlyFlagSection, &CSVOnlyFlagSection, &PPRINTOnlyFlagSection, &CompressedDataFlagSection, @@ -407,50 +406,6 @@ var SeparatorFlagSection = FlagSection{ }, } -// ================================================================ -// JSON-ONLY FLAGS - -func JSONOnlyPrintInfo() { - fmt.Println("These are flags which are applicable to JSON format.") -} - -func init() { JSONOnlyFlagSection.Sort() } - -var JSONOnlyFlagSection = FlagSection{ - name: "JSON-only flags", - infoPrinter: JSONOnlyPrintInfo, - flags: []Flag{ - - { - name: "--jvstack", - help: "Put one key-value pair per line for JSON output (multi-line output).", - parser: func(args []string, argc int, pargi *int, options *TOptions) { - options.WriterOptions.JSONOutputMultiline = true - *pargi += 1 - }, - }, - - { - name: "--no-jvstack", - help: "Put objects/arrays all on one line for JSON output.", - parser: func(args []string, argc int, pargi *int, options *TOptions) { - options.WriterOptions.JSONOutputMultiline = false - *pargi += 1 - }, - }, - - { - name: "--jlistwrap", - altNames: []string{"--jl"}, - help: "Wrap JSON output in outermost `[ ]`.", - parser: func(args []string, argc int, pargi *int, options *TOptions) { - options.WriterOptions.WrapJSONOutputInOuterList = true - *pargi += 1 - }, - }, - }, -} - // ================================================================ // PPRINT-ONLY FLAGS @@ -590,6 +545,43 @@ var LegacyFlagSection = FlagSection{ help: "Ignored as of version 6. Types are inferred/retained through the processing flow now.", parser: NoOpParse1, }, + + { + name: "--jvstack", + help: "Put one key-value pair per line for JSON output (multi-line output). This is the default for JSON output format.", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + options.WriterOptions.JSONOutputMultiline = true + *pargi += 1 + }, + }, + + { + name: "--no-jvstack", + help: "Put objects/arrays all on one line for JSON output. This is the default for JSON Lines output format.", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + options.WriterOptions.JSONOutputMultiline = false + *pargi += 1 + }, + }, + + { + name: "--jlistwrap", + altNames: []string{"--jl"}, + help: "Wrap JSON output in outermost `[ ]`. This is the default for JSON output format.", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + options.WriterOptions.WrapJSONOutputInOuterList = true + *pargi += 1 + }, + }, + + { + name: "--no-jlistwrap", + help: "Wrap JSON output in outermost `[ ]`. This is the default for JSON Lines output format.", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + options.WriterOptions.WrapJSONOutputInOuterList = false + *pargi += 1 + }, + }, }, } diff --git a/man/manpage.txt b/man/manpage.txt index 0c56b04eb..1a0c858b7 100644 --- a/man/manpage.txt +++ b/man/manpage.txt @@ -128,7 +128,6 @@ HELP OPTIONS mlr help file-format-flags mlr help flatten-unflatten-flags mlr help format-conversion-keystroke-saver-flags - mlr help json-only-flags mlr help legacy-flags mlr help miscellaneous-flags mlr help output-colorization-flags @@ -415,20 +414,14 @@ FORMAT-CONVERSION KEYSTROKE-SAVER FLAGS -p Keystroke-saver for `--nidx --fs space --repifs`. -T Keystroke-saver for `--nidx --fs tab`. -JSON-ONLY FLAGS - These are flags which are applicable to JSON format. - - --jlistwrap or --jl Wrap JSON output in outermost `[ ]`. - --jvstack Put one key-value pair per line for JSON output - (multi-line output). - --no-jvstack Put objects/arrays all on one line for JSON output. - LEGACY FLAGS These are flags which don't do anything in the current Miller version. They are accepted as no-op flags in order to keep old scripts from breaking. --jknquoteint Type information from JSON input files is now preserved throughout the processing stream. + --jlistwrap or --jl Wrap JSON output in outermost `[ ]`. This is the + default for JSON output format. --jquoteall Type information from JSON input files is now preserved throughout the processing stream. --json-fatal-arrays-on-input @@ -440,8 +433,15 @@ LEGACY FLAGS --jsonx The `--jvstack` flag is now default true in Miller 6. --jvquoteall Type information from JSON input files is now preserved throughout the processing stream. + --jvstack Put one key-value pair per line for JSON output + (multi-line output). This is the default for JSON + output format. --mmap Miller no longer uses memory-mapping to access data files. + --no-jlistwrap Wrap JSON output in outermost `[ ]`. This is the + default for JSON Lines output format. + --no-jvstack Put objects/arrays all on one line for JSON output. + This is the default for JSON Lines output format. --no-mmap Miller no longer uses memory-mapping to access data files. --ojsonx The `--jvstack` flag is now default true in Miller 6. diff --git a/man/mlr.1 b/man/mlr.1 index 4ad489038..a51421f2f 100644 --- a/man/mlr.1 +++ b/man/mlr.1 @@ -163,7 +163,6 @@ Flags: mlr help file-format-flags mlr help flatten-unflatten-flags mlr help format-conversion-keystroke-saver-flags - mlr help json-only-flags mlr help legacy-flags mlr help miscellaneous-flags mlr help output-colorization-flags @@ -512,22 +511,6 @@ available for output only. .fi .if n \{\ .RE -.SH "JSON-ONLY FLAGS" -.sp - -.if n \{\ -.RS 0 -.\} -.nf -These are flags which are applicable to JSON format. - ---jlistwrap or --jl Wrap JSON output in outermost `[ ]`. ---jvstack Put one key-value pair per line for JSON output - (multi-line output). ---no-jvstack Put objects/arrays all on one line for JSON output. -.fi -.if n \{\ -.RE .SH "LEGACY FLAGS" .sp @@ -540,6 +523,8 @@ They are accepted as no-op flags in order to keep old scripts from breaking. --jknquoteint Type information from JSON input files is now preserved throughout the processing stream. +--jlistwrap or --jl Wrap JSON output in outermost `[ ]`. This is the + default for JSON output format. --jquoteall Type information from JSON input files is now preserved throughout the processing stream. --json-fatal-arrays-on-input @@ -551,8 +536,15 @@ They are accepted as no-op flags in order to keep old scripts from breaking. --jsonx The `--jvstack` flag is now default true in Miller 6. --jvquoteall Type information from JSON input files is now preserved throughout the processing stream. +--jvstack Put one key-value pair per line for JSON output + (multi-line output). This is the default for JSON + output format. --mmap Miller no longer uses memory-mapping to access data files. +--no-jlistwrap Wrap JSON output in outermost `[ ]`. This is the + default for JSON Lines output format. +--no-jvstack Put objects/arrays all on one line for JSON output. + This is the default for JSON Lines output format. --no-mmap Miller no longer uses memory-mapping to access data files. --ojsonx The `--jvstack` flag is now default true in Miller 6. diff --git a/todo.txt b/todo.txt index a8aeb3da6..0bb97fc0a 100644 --- a/todo.txt +++ b/todo.txt @@ -12,6 +12,7 @@ JSON LINES o glossary * olh * RT cases +* --l2X and --X2l -- ? * contact re https://jsonlines.org/on_the_web/ ----------------------------------------------------------------