mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-18 00:45:47 +00:00
Improved file-not-found handling (#1508)
This commit is contained in:
parent
3201f9c675
commit
aff4b9f32d
43 changed files with 85 additions and 61 deletions
|
|
@ -65,8 +65,9 @@ func (reader *RecordReaderCSV) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
} else {
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
}
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
|
|||
|
|
@ -94,16 +94,16 @@ func (reader *RecordReaderCSVLite) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
return
|
||||
} else {
|
||||
reader.processHandle(
|
||||
handle,
|
||||
"(stdin)",
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
}
|
||||
reader.processHandle(
|
||||
handle,
|
||||
"(stdin)",
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
@ -114,17 +114,17 @@ func (reader *RecordReaderCSVLite) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
return
|
||||
} else {
|
||||
reader.processHandle(
|
||||
handle,
|
||||
filename,
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
handle.Close()
|
||||
}
|
||||
reader.processHandle(
|
||||
handle,
|
||||
filename,
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
handle.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,9 @@ func (reader *RecordReaderDKVPNIDX) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
} else {
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
}
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
|
|||
|
|
@ -45,8 +45,9 @@ func (reader *RecordReaderJSON) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
} else {
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
}
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
|
|||
|
|
@ -98,16 +98,16 @@ func (reader *RecordReaderPprintBarredOrMarkdown) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
return
|
||||
} else {
|
||||
reader.processHandle(
|
||||
handle,
|
||||
"(stdin)",
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
}
|
||||
reader.processHandle(
|
||||
handle,
|
||||
"(stdin)",
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
@ -118,17 +118,17 @@ func (reader *RecordReaderPprintBarredOrMarkdown) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
return
|
||||
} else {
|
||||
reader.processHandle(
|
||||
handle,
|
||||
filename,
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
handle.Close()
|
||||
}
|
||||
reader.processHandle(
|
||||
handle,
|
||||
filename,
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
handle.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,16 +76,16 @@ func (reader *RecordReaderTSV) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
return
|
||||
} else {
|
||||
reader.processHandle(
|
||||
handle,
|
||||
"(stdin)",
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
}
|
||||
reader.processHandle(
|
||||
handle,
|
||||
"(stdin)",
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
@ -96,17 +96,17 @@ func (reader *RecordReaderTSV) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
return
|
||||
} else {
|
||||
reader.processHandle(
|
||||
handle,
|
||||
filename,
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
handle.Close()
|
||||
}
|
||||
reader.processHandle(
|
||||
handle,
|
||||
filename,
|
||||
&context,
|
||||
readerChannel,
|
||||
errorChannel,
|
||||
downstreamDoneChannel,
|
||||
)
|
||||
handle.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,9 @@ func (reader *RecordReaderXTAB) Read(
|
|||
)
|
||||
if err != nil {
|
||||
errorChannel <- err
|
||||
} else {
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
}
|
||||
reader.processHandle(handle, "(stdin)", &context, readerChannel, errorChannel, downstreamDoneChannel)
|
||||
} else {
|
||||
for _, filename := range filenames {
|
||||
handle, err := lib.OpenFileForRead(
|
||||
|
|
|
|||
1
test/cases/non-windows/file-not-found/csv/cmd
Normal file
1
test/cases/non-windows/file-not-found/csv/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --csv cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/csv/experr
Normal file
1
test/cases/non-windows/file-not-found/csv/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/csv/expout
Normal file
0
test/cases/non-windows/file-not-found/csv/expout
Normal file
0
test/cases/non-windows/file-not-found/csv/should-fail
Normal file
0
test/cases/non-windows/file-not-found/csv/should-fail
Normal file
1
test/cases/non-windows/file-not-found/dkvp/cmd
Normal file
1
test/cases/non-windows/file-not-found/dkvp/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/dkvp/experr
Normal file
1
test/cases/non-windows/file-not-found/dkvp/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/dkvp/expout
Normal file
0
test/cases/non-windows/file-not-found/dkvp/expout
Normal file
0
test/cases/non-windows/file-not-found/dkvp/should-fail
Normal file
0
test/cases/non-windows/file-not-found/dkvp/should-fail
Normal file
1
test/cases/non-windows/file-not-found/imd/cmd
Normal file
1
test/cases/non-windows/file-not-found/imd/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --imd cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/imd/experr
Normal file
1
test/cases/non-windows/file-not-found/imd/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/imd/expout
Normal file
0
test/cases/non-windows/file-not-found/imd/expout
Normal file
0
test/cases/non-windows/file-not-found/imd/should-fail
Normal file
0
test/cases/non-windows/file-not-found/imd/should-fail
Normal file
1
test/cases/non-windows/file-not-found/json/cmd
Normal file
1
test/cases/non-windows/file-not-found/json/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --json cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/json/experr
Normal file
1
test/cases/non-windows/file-not-found/json/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
2
test/cases/non-windows/file-not-found/json/expout
Normal file
2
test/cases/non-windows/file-not-found/json/expout
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[
|
||||
]
|
||||
0
test/cases/non-windows/file-not-found/json/should-fail
Normal file
0
test/cases/non-windows/file-not-found/json/should-fail
Normal file
1
test/cases/non-windows/file-not-found/jsonl/cmd
Normal file
1
test/cases/non-windows/file-not-found/jsonl/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --jsonl cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/jsonl/experr
Normal file
1
test/cases/non-windows/file-not-found/jsonl/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/jsonl/expout
Normal file
0
test/cases/non-windows/file-not-found/jsonl/expout
Normal file
0
test/cases/non-windows/file-not-found/jsonl/should-fail
Normal file
0
test/cases/non-windows/file-not-found/jsonl/should-fail
Normal file
1
test/cases/non-windows/file-not-found/nidx/cmd
Normal file
1
test/cases/non-windows/file-not-found/nidx/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --nidx cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/nidx/experr
Normal file
1
test/cases/non-windows/file-not-found/nidx/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/nidx/expout
Normal file
0
test/cases/non-windows/file-not-found/nidx/expout
Normal file
0
test/cases/non-windows/file-not-found/nidx/should-fail
Normal file
0
test/cases/non-windows/file-not-found/nidx/should-fail
Normal file
1
test/cases/non-windows/file-not-found/pprint/cmd
Normal file
1
test/cases/non-windows/file-not-found/pprint/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --pprint cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/pprint/experr
Normal file
1
test/cases/non-windows/file-not-found/pprint/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/pprint/expout
Normal file
0
test/cases/non-windows/file-not-found/pprint/expout
Normal file
0
test/cases/non-windows/file-not-found/pprint/should-fail
Normal file
0
test/cases/non-windows/file-not-found/pprint/should-fail
Normal file
1
test/cases/non-windows/file-not-found/tsv/cmd
Normal file
1
test/cases/non-windows/file-not-found/tsv/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --tsv cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/tsv/experr
Normal file
1
test/cases/non-windows/file-not-found/tsv/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/tsv/expout
Normal file
0
test/cases/non-windows/file-not-found/tsv/expout
Normal file
0
test/cases/non-windows/file-not-found/tsv/should-fail
Normal file
0
test/cases/non-windows/file-not-found/tsv/should-fail
Normal file
1
test/cases/non-windows/file-not-found/xtab/cmd
Normal file
1
test/cases/non-windows/file-not-found/xtab/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --xtab cat /nonesuch/nope/never
|
||||
1
test/cases/non-windows/file-not-found/xtab/experr
Normal file
1
test/cases/non-windows/file-not-found/xtab/experr
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr: open /nonesuch/nope/never: no such file or directory.
|
||||
0
test/cases/non-windows/file-not-found/xtab/expout
Normal file
0
test/cases/non-windows/file-not-found/xtab/expout
Normal file
0
test/cases/non-windows/file-not-found/xtab/should-fail
Normal file
0
test/cases/non-windows/file-not-found/xtab/should-fail
Normal file
Loading…
Add table
Add a link
Reference in a new issue