diff options
author | Jani Nikula <jani@nikula.org> | 2017-10-01 23:53:14 +0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2017-10-04 22:01:40 -0300 |
commit | bc99087ff95d0cdada827f3b838d05e0c9448b63 (patch) | |
tree | e20f30db8c36a080a0e0f03923a7da68294bf373 /command-line-arguments.c | |
parent | 25960b5ecdc6374fc87a3cb12c1c393497b262da (diff) |
cli: add .present field to opt desc to check if the arg was present
Add pointer to boolean .present field to opt desc, which (if non-NULL)
will be set to TRUE if the argument in question is present on the
command line. Unchanged otherwise.
Diffstat (limited to 'command-line-arguments.c')
-rw-r--r-- | command-line-arguments.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/command-line-arguments.c b/command-line-arguments.c index f1a5b232..39940d5f 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -128,6 +128,8 @@ parse_position_arg (const char *arg_str, int pos_arg_index, if (arg_desc->opt_position) { if (pos_arg_counter == pos_arg_index) { *arg_desc->opt_position = arg_str; + if (arg_desc->present) + *arg_desc->present = TRUE; return TRUE; } pos_arg_counter++; @@ -202,10 +204,13 @@ parse_option (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_ else INTERNAL_ERROR ("unknown or unhandled option \"%s\"", try->name); - if (opt_status) - return opt_index+1; - else + if (! opt_status) return -1; + + if (try->present) + *try->present = TRUE; + + return opt_index+1; } return -1; } |