-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept filenames at start or end of command
When editing a pipeline (e.g. from shell history), it's a lot easier to change the file if it's near the front, rather than needing to pick a filename out from between a long list of options to `adifmt edit` and a long pipeline chain after it. `adifmt command file1.adi --option1=foo --option2=bar file2.adi` works `adifmt command --option1=foo file1.adi --option2.bar file2.adi` doesn't (option parsing stops at the first non-flag).
- Loading branch information
Showing
3 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Tests that filenames can come before or after flags (or both) but filenames | ||
# can't come in the middle of flags. | ||
|
||
# File before flags | ||
exec adifmt cat foo.tsv bar.tsv --output json --json-indent 2 | ||
cmp stdout combined.json | ||
! stderr . | ||
|
||
# File after flags | ||
exec adifmt cat --output json --json-indent 2 foo.tsv bar.tsv | ||
cmp stdout combined.json | ||
! stderr . | ||
|
||
# One file before and one after | ||
exec adifmt cat foo.tsv --output json --json-indent 2 bar.tsv | ||
cmp stdout combined.json | ||
! stderr . | ||
|
||
# First filename stops flag parsing, so if there are flags leftover you'll get | ||
# a file-not-found error. | ||
! exec adifmt cat --output json foo.tsv --json-indent 2 bar.tsv | ||
! stdout . | ||
stderr '--json-indent: no such file' | ||
|
||
# Double dash stops flag parsing | ||
cp foo.tsv -with-hyphen.tsv | ||
exec adifmt cat --output json --json-indent 2 -- -with-hyphen.tsv bar.tsv | ||
cmp stdout combined.json | ||
! stderr . | ||
|
||
-- foo.tsv -- | ||
CALL MODE | ||
K1A CW | ||
W2B SSB | ||
-- bar.tsv -- | ||
CALL MODE | ||
K3C FM | ||
W4D RTTY | ||
-- combined.json -- | ||
{ | ||
"HEADER": { | ||
"ADIF_VER": "3.1.4", | ||
"CREATED_TIMESTAMP": "23450607 080910", | ||
"PROGRAMID": "adifmt", | ||
"PROGRAMVERSION": "(devel)" | ||
}, | ||
"RECORDS": [ | ||
{ | ||
"CALL": "K1A", | ||
"MODE": "CW" | ||
}, | ||
{ | ||
"CALL": "W2B", | ||
"MODE": "SSB" | ||
}, | ||
{ | ||
"CALL": "K3C", | ||
"MODE": "FM" | ||
}, | ||
{ | ||
"CALL": "W4D", | ||
"MODE": "RTTY" | ||
} | ||
] | ||
} |