diff options
author | Jani Nikula <jani@nikula.org> | 2014-01-10 23:28:53 +0200 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-01-18 14:45:26 -0400 |
commit | c7453773064efbd0b2cd17b15ba483edbd28ce1e (patch) | |
tree | 00d526c4d671c4a793573fff423888d4b81beb05 /notmuch-config.c | |
parent | 17e44cd584017c9187860e0dc80ea407940b8939 (diff) |
cli: clean up exit status code returned by the cli commands
Apart from the status codes for format mismatches, the non-zero exit
status codes have been arbitrary. Make the cli consistently return
either EXIT_SUCCESS or EXIT_FAILURE.
Diffstat (limited to 'notmuch-config.c')
-rw-r--r-- | notmuch-config.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/notmuch-config.c b/notmuch-config.c index 6845e3c3..e06142b5 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -839,34 +839,39 @@ notmuch_config_command_list (notmuch_config_t *config) int notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) { + int ret; + argc--; argv++; /* skip subcommand argument */ if (argc < 1) { fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); - return 1; + return EXIT_FAILURE; } if (strcmp (argv[0], "get") == 0) { if (argc != 2) { fprintf (stderr, "Error: notmuch config get requires exactly " "one argument.\n"); - return 1; + return EXIT_FAILURE; } - return notmuch_config_command_get (config, argv[1]); + ret = notmuch_config_command_get (config, argv[1]); } else if (strcmp (argv[0], "set") == 0) { if (argc < 2) { fprintf (stderr, "Error: notmuch config set requires at least " "one argument.\n"); - return 1; + return EXIT_FAILURE; } - return notmuch_config_command_set (config, argv[1], argc - 2, argv + 2); + ret = notmuch_config_command_set (config, argv[1], argc - 2, argv + 2); } else if (strcmp (argv[0], "list") == 0) { - return notmuch_config_command_list (config); + ret = notmuch_config_command_list (config); + } else { + fprintf (stderr, "Unrecognized argument for notmuch config: %s\n", + argv[0]); + return EXIT_FAILURE; } - fprintf (stderr, "Unrecognized argument for notmuch config: %s\n", - argv[0]); - return 1; + return ret ? EXIT_FAILURE : EXIT_SUCCESS; + } notmuch_bool_t |