Skip to content

Commit

Permalink
Support PPRINT barred input
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jan 20, 2024
1 parent 76408f3 commit 51cd244
Show file tree
Hide file tree
Showing 4 changed files with 476 additions and 22 deletions.
15 changes: 13 additions & 2 deletions pkg/cli/option_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,24 @@ var PPRINTOnlyFlagSection = FlagSection{
},

{
name: "--barred",
help: "Prints a border around PPRINT output (not available for input).",
name: "--barred",
altNames: []string{"--barred-output"},
help: "Prints a border around PPRINT output (not available for input).",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.WriterOptions.BarredPprintOutput = true
*pargi += 1
},
},

{
name: "--barred-input",
help: "TO DO: WRITE ME.",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.ReaderOptions.BarredPprintInput = true
options.ReaderOptions.IFS = "|"
*pargi += 1
},
},
},
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/option_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type TReaderOptions struct {
AllowRaggedCSVInput bool
CSVLazyQuotes bool
CSVTrimLeadingSpace bool
BarredPprintInput bool

CommentHandling TCommentHandling
CommentString string
Expand Down
20 changes: 0 additions & 20 deletions pkg/input/record_reader_csvlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,6 @@ func NewRecordReaderCSVLite(
return reader, nil
}

func NewRecordReaderPPRINT(
readerOptions *cli.TReaderOptions,
recordsPerBatch int64,
) (*RecordReaderCSVLite, error) {
reader := &RecordReaderCSVLite{
readerOptions: readerOptions,
recordsPerBatch: recordsPerBatch,
fieldSplitter: newFieldSplitter(readerOptions),

useVoidRep: true,
voidRep: "-",
}
if reader.readerOptions.UseImplicitCSVHeader {
reader.recordBatchGetter = getRecordBatchImplicitCSVHeader
} else {
reader.recordBatchGetter = getRecordBatchExplicitCSVHeader
}
return reader, nil
}

func (reader *RecordReaderCSVLite) Read(
filenames []string,
context types.Context,
Expand Down
Loading

0 comments on commit 51cd244

Please sign in to comment.