aboutsummaryrefslogtreecommitdiff
path: root/test/arg-test.c
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2017-12-25 14:42:26 -0400
committerDavid Bremner <david@tethera.net>2017-12-29 16:45:35 -0400
commit0ada2a05c94de72bc2c7c57a790e92b77af37a42 (patch)
tree3eecbe5d2807be6fb01cb4e2b8b565f40fe050e6 /test/arg-test.c
parent07a6214233ebc1a9c228acae674cffe68d0908ea (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/arg-test.c')
-rw-r--r--test/arg-test.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/arg-test.c b/test/arg-test.c
index 7aff8255..a218f967 100644
--- a/test/arg-test.c
+++ b/test/arg-test.c
@@ -7,13 +7,14 @@ int main(int argc, char **argv){
int opt_index=1;
int kw_val=0;
+ int kwb_val=0;
int fl_val=0;
int int_val=0;
const char *pos_arg1=NULL;
const char *pos_arg2=NULL;
const char *string_val=NULL;
bool bool_val = false;
- bool fl_set = false, int_set = false, bool_set = false,
+ bool fl_set = false, int_set = false, bool_set = false, kwb_set = false,
kw_set = false, string_set = false, pos1_set = false, pos2_set = false;
notmuch_opt_desc_t parent_options[] = {
@@ -33,6 +34,12 @@ int main(int argc, char **argv){
{ "one", 1 },
{ "two", 2 },
{ 0, 0 } } },
+ { .opt_keyword = &kwb_val, .name = "boolkeyword", .present = &kwb_set,
+ .keyword_no_arg_value = "true", .keywords =
+ (notmuch_keyword_t []){ { "false", 0 },
+ { "true", 1 },
+ { "auto", 2 },
+ { 0, 0 } } },
{ .opt_inherit = parent_options },
{ .opt_string = &string_val, .name = "string", .present = &string_set },
{ .opt_position = &pos_arg1, .present = &pos1_set },
@@ -51,6 +58,9 @@ int main(int argc, char **argv){
if (kw_set)
printf("keyword %d\n", kw_val);
+ if (kwb_set)
+ printf("boolkeyword %d\n", kwb_val);
+
if (fl_set)
printf("flags %d\n", fl_val);