Skip to content

Commit

Permalink
Internal name-neatens
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jan 20, 2024
1 parent aff07ef commit e5d6488
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 23 deletions.
10 changes: 5 additions & 5 deletions pkg/cli/option_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ var CSVTSVOnlyFlagSection = FlagSection{
altNames: []string{"--no-implicit-tsv-header"},
help: "Opposite of `--implicit-csv-header`. This is the default anyway -- the main use is for the flags to `mlr join` if you have main file(s) which are headerless but you want to join in on a file which does have a CSV/TSV header. Then you could use `mlr --csv --implicit-csv-header join --no-implicit-csv-header -l your-join-in-with-header.csv ... your-headerless.csv`.",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.ReaderOptions.UseImplicitCSVHeader = false
options.ReaderOptions.UseImplicitHeader = false
*pargi += 1
},
},
Expand All @@ -2179,7 +2179,7 @@ var CSVTSVOnlyFlagSection = FlagSection{
altNames: []string{"--headerless-csv-input", "--hi", "--implicit-tsv-header"},
help: "Use 1,2,3,... as field labels, rather than from line 1 of input files. Tip: combine with `label` to recreate missing headers.",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.ReaderOptions.UseImplicitCSVHeader = true
options.ReaderOptions.UseImplicitHeader = true
*pargi += 1
},
},
Expand All @@ -2189,7 +2189,7 @@ var CSVTSVOnlyFlagSection = FlagSection{
altNames: []string{"--ho", "--headerless-tsv-output"},
help: "Print only CSV/TSV data lines; do not print CSV/TSV header lines.",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.WriterOptions.HeaderlessCSVOutput = true
options.WriterOptions.HeaderlessOutput = true
*pargi += 1
},
},
Expand All @@ -2198,8 +2198,8 @@ var CSVTSVOnlyFlagSection = FlagSection{
name: "-N",
help: "Keystroke-saver for `--implicit-csv-header --headerless-csv-output`.",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.ReaderOptions.UseImplicitCSVHeader = true
options.WriterOptions.HeaderlessCSVOutput = true
options.ReaderOptions.UseImplicitHeader = true
options.WriterOptions.HeaderlessOutput = true
*pargi += 1
},
},
Expand Down
14 changes: 7 additions & 7 deletions pkg/cli/option_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ type TReaderOptions struct {
irsWasSpecified bool
allowRepeatIFSWasSpecified bool

UseImplicitCSVHeader bool
AllowRaggedCSVInput bool
CSVLazyQuotes bool
CSVTrimLeadingSpace bool
BarredPprintInput bool
UseImplicitHeader bool
AllowRaggedCSVInput bool
CSVLazyQuotes bool
CSVTrimLeadingSpace bool
BarredPprintInput bool

CommentHandling TCommentHandling
CommentString string
Expand Down Expand Up @@ -96,7 +96,7 @@ type TWriterOptions struct {
opsWasSpecified bool
orsWasSpecified bool

HeaderlessCSVOutput bool
HeaderlessOutput bool
BarredPprintOutput bool
RightAlignedPPRINTOutput bool
RightAlignedXTABOutput bool
Expand Down Expand Up @@ -214,7 +214,7 @@ func DefaultWriterOptions() TWriterOptions {
FLATSEP: ".",
FlushOnEveryRecord: true,

HeaderlessCSVOutput: false,
HeaderlessOutput: false,

WrapJSONOutputInOuterList: true,
JSONOutputMultiline: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/input/record_reader_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (reader *RecordReaderCSV) processHandle(
// Reset state for start of next input file
reader.filename = filename
reader.rowNumber = 0
reader.needHeader = !reader.readerOptions.UseImplicitCSVHeader
reader.needHeader = !reader.readerOptions.UseImplicitHeader
reader.header = nil

csvReader := csv.NewReader(NewBOMStrippingReader(handle))
Expand Down
2 changes: 1 addition & 1 deletion pkg/input/record_reader_csvlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewRecordReaderCSVLite(
useVoidRep: false,
voidRep: "",
}
if reader.readerOptions.UseImplicitCSVHeader {
if reader.readerOptions.UseImplicitHeader {
reader.recordBatchGetter = getRecordBatchImplicitCSVHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitCSVHeader
Expand Down
5 changes: 2 additions & 3 deletions pkg/input/record_reader_pprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewRecordReaderPPRINT(
separatorMatcher: regexp.MustCompile(`^\+[-+]*\+`),
fieldSplitter: newFieldSplitter(readerOptions),
}
if reader.readerOptions.UseImplicitCSVHeader {
if reader.readerOptions.UseImplicitHeader {
reader.recordBatchGetter = getRecordBatchImplicitPprintHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitPprintHeader
Expand All @@ -67,8 +67,7 @@ func NewRecordReaderPPRINT(
useVoidRep: true,
voidRep: "-",
}
// XXX RENAME THERE
if reader.readerOptions.UseImplicitCSVHeader {
if reader.readerOptions.UseImplicitHeader {
reader.recordBatchGetter = getRecordBatchImplicitCSVHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitCSVHeader
Expand Down
2 changes: 1 addition & 1 deletion pkg/input/record_reader_tsv.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewRecordReaderTSV(
recordsPerBatch: recordsPerBatch,
fieldSplitter: newFieldSplitter(readerOptions),
}
if reader.readerOptions.UseImplicitCSVHeader {
if reader.readerOptions.UseImplicitHeader {
reader.recordBatchGetter = getRecordBatchImplicitTSVHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitTSVHeader
Expand Down
2 changes: 1 addition & 1 deletion pkg/output/record_writer_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (writer *RecordWriterCSV) Write(
needToPrintHeader = true
}

if needToPrintHeader && !writer.writerOptions.HeaderlessCSVOutput {
if needToPrintHeader && !writer.writerOptions.HeaderlessOutput {
fields := make([]string, outrec.FieldCount)
i := 0
for pe := outrec.Head; pe != nil; pe = pe.Next {
Expand Down
2 changes: 1 addition & 1 deletion pkg/output/record_writer_csvlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (writer *RecordWriterCSVLite) Write(
needToPrintHeader = true
}

if needToPrintHeader && !writer.writerOptions.HeaderlessCSVOutput {
if needToPrintHeader && !writer.writerOptions.HeaderlessOutput {
for pe := outrec.Head; pe != nil; pe = pe.Next {
bufferedOutputStream.WriteString(colorizer.MaybeColorizeKey(pe.Key, outputIsStdout))

Expand Down
4 changes: 2 additions & 2 deletions pkg/output/record_writer_pprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (writer *RecordWriterPPRINT) writeHeterogenousListNonBarred(
outrec := e.Value.(*mlrval.Mlrmap)

// Print header line
if onFirst && !writer.writerOptions.HeaderlessCSVOutput {
if onFirst && !writer.writerOptions.HeaderlessOutput {
for pe := outrec.Head; pe != nil; pe = pe.Next {
if !writer.writerOptions.RightAlignedPPRINTOutput { // left-align
if pe.Next != nil {
Expand Down Expand Up @@ -257,7 +257,7 @@ func (writer *RecordWriterPPRINT) writeHeterogenousListBarred(
outrec := e.Value.(*mlrval.Mlrmap)

// Print header line
if onFirst && !writer.writerOptions.HeaderlessCSVOutput {
if onFirst && !writer.writerOptions.HeaderlessOutput {
bufferedOutputStream.WriteString(horizontalStart)
for pe := outrec.Head; pe != nil; pe = pe.Next {
bufferedOutputStream.WriteString(horizontalBars[pe.Key])
Expand Down
2 changes: 1 addition & 1 deletion pkg/output/record_writer_tsv.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (writer *RecordWriterTSV) Write(
needToPrintHeader = true
}

if needToPrintHeader && !writer.writerOptions.HeaderlessCSVOutput {
if needToPrintHeader && !writer.writerOptions.HeaderlessOutput {
for pe := outrec.Head; pe != nil; pe = pe.Next {
bufferedOutputStream.WriteString(
colorizer.MaybeColorizeKey(
Expand Down

0 comments on commit e5d6488

Please sign in to comment.