diff options
| author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2017-12-25 14:42:26 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-12-29 16:45:35 -0400 |
| commit | 0ada2a05c94de72bc2c7c57a790e92b77af37a42 (patch) | |
| tree | 3eecbe5d2807be6fb01cb4e2b8b565f40fe050e6 /test/T410-argument-parsing.sh | |
| parent | 07a6214233ebc1a9c228acae674cffe68d0908ea (diff) | |
cli: some keyword options can be supplied with no argument
We might change some notmuch command line tools that used to be
booleans into keyword arguments.
In that case, there are some legacy tools that will expect to be able
to do "notmuch foo --bar" instead of "notmuch foo --bar=baz".
This patch makes it possible to support that older API, while
providing a warning and an encouragement to upgrade.
Diffstat (limited to 'test/T410-argument-parsing.sh')
| -rwxr-xr-x | test/T410-argument-parsing.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh index 192133c5..a384ce86 100755 --- a/test/T410-argument-parsing.sh +++ b/test/T410-argument-parsing.sh @@ -65,4 +65,36 @@ flags 1 EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "test keyword arguments without value" +$TEST_DIRECTORY/arg-test --boolkeyword bananas > OUTPUT +cat <<EOF > EXPECTED +boolkeyword 1 +positional arg 1 bananas +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "test keyword arguments with non-default value separted by a space" +$TEST_DIRECTORY/arg-test --boolkeyword false bananas > OUTPUT +cat <<EOF > EXPECTED +boolkeyword 0 +positional arg 1 bananas +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "test keyword arguments without value at the end" +$TEST_DIRECTORY/arg-test bananas --boolkeyword > OUTPUT +cat <<EOF > EXPECTED +boolkeyword 1 +positional arg 1 bananas +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "test keyword arguments without value but with = (should be an error)" +$TEST_DIRECTORY/arg-test bananas --boolkeyword= > OUTPUT 2>&1 +cat <<EOF > EXPECTED +Unknown keyword argument "" for option "boolkeyword". +Unrecognized option: --boolkeyword= +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done |
