From 61f0a5b8ee2adf540106a09c5f83fe634da6beb3 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Fri, 21 Oct 2011 09:19:17 -0300 Subject: cli: change argument parsing convention for subcommands previously we deleted the subcommand name from argv before passing to the subcommand. In this version, the deletion is done in the actual subcommands. Although this causes some duplication of code, it allows us to be more flexible about how we parse command line arguments in the subcommand, including possibly using off-the-shelf routines like getopt_long that expect the name of the command in argv[0]. --- notmuch-count.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'notmuch-count.c') diff --git a/notmuch-count.c b/notmuch-count.c index 39f08c6c..0d700a9e 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -35,6 +35,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST; #endif + argc--; argv++; /* skip subcommand argument */ + for (i = 0; i < argc && argv[i][0] == '-'; i++) { if (strcmp (argv[i], "--") == 0) { i++; -- cgit v1.2.3