Internal name-neatens (#1475)

This commit is contained in:
John Kerl 2024-01-20 13:36:28 -05:00 committed by GitHub
parent aff07efe3a
commit bfc829a381
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 22 additions and 23 deletions

View file

@ -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
},
},
@ -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
},
},
@ -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
},
},
@ -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
},
},

View file

@ -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
@ -96,7 +96,7 @@ type TWriterOptions struct {
opsWasSpecified bool
orsWasSpecified bool
HeaderlessCSVOutput bool
HeaderlessOutput bool
BarredPprintOutput bool
RightAlignedPPRINTOutput bool
RightAlignedXTABOutput bool
@ -214,7 +214,7 @@ func DefaultWriterOptions() TWriterOptions {
FLATSEP: ".",
FlushOnEveryRecord: true,
HeaderlessCSVOutput: false,
HeaderlessOutput: false,
WrapJSONOutputInOuterList: true,
JSONOutputMultiline: true,

View file

@ -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))

View file

@ -70,7 +70,7 @@ func NewRecordReaderCSVLite(
useVoidRep: false,
voidRep: "",
}
if reader.readerOptions.UseImplicitCSVHeader {
if reader.readerOptions.UseImplicitHeader {
reader.recordBatchGetter = getRecordBatchImplicitCSVHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitCSVHeader

View file

@ -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
@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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))

View file

@ -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 {
@ -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])

View file

@ -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(