diff options
Diffstat (limited to 'src/args.c')
-rw-r--r-- | src/args.c | 39 |
1 files changed, 18 insertions, 21 deletions
@@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,7 +97,7 @@ static void usage(void) "calcurse [-D <directory>] [-C <directory>] [-c <calendar file>]\n" "calcurse -Q [--from <date>] [--to <date>] [--days <number>]\n" "calcurse -a | -d <date> | -d <number> | -n | -r[<number>] | -s[<date>] | -t[<number>]\n" - "calcurse -h | -v | --status | -G | -P | -g | -i <file> | -x[<file>] | --daemon")); + "calcurse -h | -v | --status | -G | -P | -g | -i <file> | -x[<format>] | --daemon")); } static void usage_try(void) @@ -112,7 +112,7 @@ static void version_arg(void) { printf(_("calcurse %s -- text-based organizer\n"), VERSION); putchar('\n'); - printf("%s\n", _("Copyright (c) 2004-2020 calcurse Development Team.")); + printf("%s\n", _("Copyright (c) 2004-2023 calcurse Development Team.")); printf("%s\n", _("This is free software; see the source for copying conditions.")); } @@ -149,7 +149,7 @@ static void help_arg(void) printf("%s\n", _(" -g, --gc Run the garbage collector")); printf("%s\n", _(" -h, --help Show this help text")); printf("%s\n", _(" -i, --import <file> Import iCal data from file")); - printf("%s\n", _(" -q, --quiet Suppress system dialogs")); + printf("%s\n", _(" -q, --quiet Suppress import/export result message")); printf("%s\n", _(" --read-only Do not save configuration or data files")); printf("%s\n", _(" --status Display status of running instances")); printf("%s\n", _(" -v, --version Show version information")); @@ -398,7 +398,7 @@ cleanup: /* * Parse the command-line arguments and call the appropriate * routines to handle those arguments. Also initialize the data paths. - * Returns the non-interactive value. + * Exit here in case of errors else return the non-interactive value. */ int parse_args(int argc, char **argv) { @@ -428,7 +428,7 @@ int parse_args(int argc, char **argv) const char *cfile = NULL, *confdir = NULL; char *ifile = NULL; - int non_interactive = 1; + int ret, non_interactive = 1; int ch, cpid, type; regex_t reg; char buf[BUFSIZ]; @@ -515,6 +515,10 @@ int parse_args(int argc, char **argv) case 'c': cfile = optarg; break; + case '?': + usage(); + usage_try(); + exit(EXIT_FAILURE); \ } } io_init(cfile, datadir, confdir); @@ -557,7 +561,7 @@ int parse_args(int argc, char **argv) break; case 'h': help_arg(); - goto cleanup; + exit(EXIT_SUCCESS); case 'g': gc = 1; break; @@ -615,7 +619,7 @@ int parse_args(int argc, char **argv) break; case 'v': version_arg(); - goto cleanup; + exit(EXIT_SUCCESS); case 'x': export = 1; if (optarg) { @@ -860,10 +864,6 @@ int parse_args(int argc, char **argv) '\0'; cmd_line = 1; break; - default: - usage(); - usage_try(); - goto cleanup; } } @@ -876,12 +876,8 @@ int parse_args(int argc, char **argv) (format_opt && !(grep + query + dump_imported)) || (query_range && !query) || (purge && !filter.invert) - ) { - ERROR_MSG(_("invalid argument combination")); - usage(); - usage_try(); - goto cleanup; - } + ) + EXIT(_("invalid argument combination")); EXIT_IF(to >= 0 && range, _("cannot specify a range and an end date")); if (from == -1) @@ -967,10 +963,12 @@ int parse_args(int argc, char **argv) fmt_apt = fmt_rapt = fmt_ev = fmt_rev = NULL; fmt_todo = NULL; } - io_import_data(IO_IMPORT_ICAL, ifile, fmt_ev, fmt_rev, fmt_apt, - fmt_rapt, fmt_todo); + ret = io_import_data(IO_IMPORT_ICAL, ifile, fmt_ev, fmt_rev, + fmt_apt, fmt_rapt, fmt_todo); io_save_apts(path_apts); io_save_todo(path_todo); + if (!ret) + exit_calcurse(EXIT_FAILURE); } else if (export) { io_check_file(path_apts); io_check_file(path_todo); @@ -984,7 +982,6 @@ int parse_args(int argc, char **argv) non_interactive = 0; } -cleanup: /* Free filter parameters. */ if (filter.regex) regfree(filter.regex); |