aboutsummaryrefslogtreecommitdiffstats
path: root/src/args.c
Commit message (Collapse)AuthorAgeFilesLines
* CLI: long options to override configuration file settingsLars Henriksen2019-01-071-3/+29
| | | | | | | | | | The input and output date formats may be set from the command line. Intended for scripts that must be independent of the local user configuration. Cannot be used in interactive mode. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* CLI: take input date format from configuration file, do not accept timeLars Henriksen2019-01-071-68/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch the input date parsing accepts three formats: yyyy/mm/dd, mm/dd/yyyy, yyyy-mm-dd. They are tried in sequence. It also accepts an additional time (hh:mm), or a time without a date. There are several issues with this: - it is not documented - the date format dd/mm/yyyy is not accepted - print_date() and filter option settings (in parse_args()) can only handle midnight times (which are the result of a date without time) - it is highly uncertain what happens if a time (without a date) is given; at least the -d option treats a time without colon (1215 for 12:15) as a number It seems that acceptance of time input is a by-product and not needed. For these reasons the input date parsing has been changed: - the format is taken from the configuration file (as is the case for the output date format) - only a date, and no time, is accepted Because the input date format is used during parsing of the command line, the configuration file must be loaded first, i.e. the options -D or -C must be parsed before the remaining ones. Loading the configuration file may result in errors (e.g. caused by changes between versions). For this reason config_load() has been made more tolerant and issues warnings instead of exiting. A followup patch will introduce two options to allow the configuration file settings to be overridden for input and output date formats. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Command line options: -P, option check, usage, helpLars Henriksen2019-01-071-25/+69
| | | | | | | | | | Option -F/--filter renamed to -P/--purge; -F retained as deprecated. Check for non-option arguments and for filter, format and query-range options only. Update of help and usage messages. Fixed --status output when calcurse is not running. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix day range for queriesLars Henriksen2019-01-071-8/+6
| | | | | | | | | | | | | | | | In "--from a --to z", a is included in the range, z not. This is non-intuitive and disagrees with the semantics of "to" in filter options like --filter-start-to, where "to" (and "from") are used inclusively (as opposed to "before" and "after"). It also has the effect that "--from today --to tomorrow" has a range of 1 day, "--to z" a range of 0 days (otherwise not allowed), and "--to today --days -1" is allowed and displays yesterday! The implementation has been fixed to agree with "inclusive" semantics. Options --from and -days with negative range are allowed, while --to and --days are disallowed also when the range is negative. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Rewrite of io_init()Lars Henriksen2018-12-141-1/+3
| | | | | | | | | | | | | | The introduction of the "-C <confdir>" option is an opportunity to review the initialization of data paths. It lead to a rewrite. Two "root" directories are used (data and configuration files); by default they are identical. The statically allocated path buffers are turned into dynamically allocated buffers. Missing files/directories now include hooks. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Only reload if data files were changed (replacement)Lars Henriksen2018-10-211-6/+5
| | | | | | | | | | | | | | This is a replacement for commits 57dd3d6 and 912124b. The idea is to move the check for modified files and the list initialization into io_load_data(), and let io_load_data() decide what to load. A new argument is used to force a load. The return code from new_data() (the renamed version of io_check_data_files_modified()) tells which files have changed. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Initialize variables in non-interactive mode in all casesLars Henriksen2018-08-191-3/+1
| | | | | | | | | The changed handling of thread ids implies that they must be initialized before exit of calcurse where they are used. Hence the function vars_init() is now called irrespective of command line arguments. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use a path instead of a file for -C optionQuentin Hibon2018-08-051-5/+5
| | | | | | | | | | | | Allows to specify a configuration directory containing: * conf * keys * hooks When used in combination with -D $ddir, $ddir contains all the other files not mentioned above. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add option to specify the configuration file usedQuentin Hibon2018-05-281-4/+10
| | | | | | | | | The configuration file (~/.calcurse/conf by default) can now be specified with -C or --conf. Workaround for GitHub issue #86. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Allow for passing negative arguments to -dLukas Fleischer2017-12-131-10/+14
| | | | | | | | When specifying date ranges using -d, allow for passing negative values to indicate that the date range should start a certain number of days ago. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Check for optional argument to -s optionLars Henriksen2017-08-121-0/+2
| | | | | Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2017-01-121-2/+2
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Do not start the daemon more than onceLukas Fleischer2016-10-191-0/+1
| | | | | | | | | Avoid starting multiple daemon instances if the --daemon argument is passed and the daemon is already running. Terminate the already running instance before spawning a new one instead. Suggested-by: Vlad Glagolev <scm@vaygr.net> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Always use memory management wrappersLukas Fleischer2016-10-131-2/+2
| | | | | | | Use mem_*() wrappers instead of directly accessing libc functions when allocating/deallocating memory. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Support format strings when dumping imported itemsLukas Fleischer2016-02-111-6/+23
| | | | | | | | | | | | | | In commit 3eae7ce (Add --list-imported command line option, 2016-01-12), we added an option to print the hashes of imported items to stdout. Extend this command line option such that it dumps the items using the specified formatting strings. With the new behavior it is, for example, easier to check items for import errors. Also, rename the option from --list-imported to --dump-imported (it is not part of any official release yet so we do not need to care about backwards compatibility). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Support format specifiers in grep modeLukas Fleischer2016-02-051-7/+24
| | | | | | | Honor --format-* parameters when using the -G operation. In the case of recurring items, the first occurrence is used. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactor grep modeLukas Fleischer2016-02-051-2/+7
| | | | | | | | | Split io_save_{apts,todo}() into functions that write raw data to a file and functions that write formatted items to stdout such that one can easily extend the grep mode for format string support in a follow-up commit. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2016-01-301-2/+2
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix behavior of --todo with an optional argumentLukas Fleischer2016-01-281-0/+2
| | | | | | | | | | The previous behavior of --todo was to always only list uncompleted items, unless zero was specified as additional argument. Restore and document this behavior. Also, fix two tests that failed because the --todo output is now sorted. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* args.c: Revise help/usage/version outputLukas Fleischer2016-01-281-86/+33
| | | | | | | Remove obsolete options from the help text, add new options, clean everything up, cut translatable strings into atomic chunks. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add a --daemon command-line parameterLukas Fleischer2016-01-281-3/+11
| | | | | | | When specifying --daemon, calcurse immediately forks and runs the notification daemon in the background. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Export item UIDs upon requestLukas Fleischer2016-01-151-2/+7
| | | | | | | Add a new --export-uid command line option that adds each item's hash to the UID property when exporting. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add --list-imported command line optionLukas Fleischer2016-01-131-1/+7
| | | | | | | When this option is used together with -i/--import, the object identifiers of imported objects are printed to stdout. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add command line option to suppress dialogsLukas Fleischer2016-01-131-1/+5
| | | | | | | Implement a -q/--quiet command line option to disable system dialogs temporarily. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Implement filter modeLukas Fleischer2016-01-131-4/+8
| | | | | | | Add a new -F mode that is identical to -G but writes the result back to the calcurse data files instead of stdout. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add an option to filter by object hashLukas Fleischer2016-01-131-1/+6
| | | | | | | | | Implement a new --filter-hash option to filter by object identifiers. Each object having an identifier that has the specified pattern as a prefix is matched. Patterns starting with an exclamation mark (!) are interpreted as negative patterns. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use time_t instead of long in several placesLukas Fleischer2015-02-241-5/+6
| | | | | | | Start converting some variables and return values to store times from long to time_t. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use date_sec_change() for adding day deltasLukas Fleischer2015-02-221-4/+4
| | | | | | Fixes tests range-002.sh and search-001.sh. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use LONG_MAX for invalid dates in parse_datearg()Lukas Fleischer2015-02-221-3/+3
| | | | | | We cannot use -1 here since negative values are valid dates. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2015-02-071-2/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Handle dates past January 19th, 2038Lukas Fleischer2015-02-071-2/+2
| | | | | | Try to support dates past year 2038 on systems with 64-bit time_t. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add io_load_data() wrapperLukas Fleischer2014-10-101-10/+5
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix parsing of times in parse_datetimearg()Lukas Fleischer2014-08-091-2/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Extend date formats for filtersLukas Fleischer2014-08-091-14/+48
| | | | | | | Allow for specifying both date and time in all dates and date ranges used in filters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add --filter-{start,end}-rangeLukas Fleischer2014-08-081-0/+48
| | | | | | | These are shorthands for --filter-start-from/--filter-start-to and --filter-end-from/--filter-end-to. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add a grep modeLukas Fleischer2014-08-071-3/+18
| | | | | | | This allows for printing a subset of the items in the data files by using filters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* args.c: Reword error messagesLukas Fleischer2014-08-061-14/+14
| | | | | | | Use the same error message if option arguments have the same data type and always add the violating value. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use backwards-compatible out format for queriesLukas Fleischer2014-08-061-10/+13
| | | | | | | | | | | Print TODO items before appointments in query outputs and add an empty line between the list of TODO items and the list of appointments. This is how items were printed before the big parser refactoring. Also, add a test to ensure we do not unintentionally change that format in the future. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not use filters in GC or import modeLukas Fleischer2014-08-061-4/+4
| | | | | | | Filtering items when running garbage collection or when importing data might result in data loss, so simply ignore filters here. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rework command line argument handlingLukas Fleischer2014-08-061-431/+164
| | | | | | | | | | | Add a new range query mode (--days) and refactor the command line argument parser. Note: This slightly changes the behavior of some command line parameters, since date arguments no longer use the input date format from the configuration file! Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow for filtering TODO itemsLukas Fleischer2014-08-061-6/+28
| | | | | | | | | | | The item filters now apply to both appointments and TODO items. Also, add a new type mask "todo" and the following new filter options: * --filter-priority * --filter-completed * --filter-uncompleted Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add a query modeLukas Fleischer2014-08-061-6/+69
| | | | | | | | | | Add a new parameter -Q that can be used to print all appointments inside a given query range, followed by all TODO items. The date range can be specified using the --from and --to arguments. The start date defaults to the current day, the end date defaults to the day after the start date if not specified. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add pattern filter optionLukas Fleischer2014-08-061-33/+31
| | | | | | | This adds a new item filter option --filter-pattern and removes the whole -S parameter logic, while making -S an alias for --filter-pattern. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add item filtersLukas Fleischer2014-08-061-7/+118
| | | | | | | | | | | | | | | | | This adds the following filter options that allow for restricting the set of items that are read from the appointments file: * --filter-type * --filter-start-from * --filter-start-to * --filter-start-after * --filter-start-before * --filter-end-from * --filter-end-to * --filter-end-after * --filter-end-before Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow for merging data files when reloadingLukas Fleischer2014-07-161-2/+2
| | | | | | | | This allows for merging the (unsaved) items with the items from the data files when invoking the reload operation. To this end, an external merge tool (defaults to vimdiff) is used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix segmentation faultLukas Fleischer2014-06-251-1/+1
| | | | | | | | | | This adds some more accurate checks to avoid a segmentation fault that occurred when accessing a nonexistent item. Fixes GitHub issue #7. Reported-by: Bromind <martin.vassor@hotmail.fr> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reintroduce heading and separator in appointmentsLukas Fleischer2014-05-181-1/+1
| | | | | | | This re-introduces the heading (showing the POM and the current date) as well as the separating line between events and appointments. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ui-day: Large-scale refactoringLukas Fleischer2014-05-181-1/+3
| | | | | | | | | | Use the generic list box implementation for the appointments panel. This results in some major changes to how the items are printed. Note that this temporarily removes the heading showing the POM and the date as well as the separating line between events and appointments. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add -l/--limit optionWilliam Pettersson2013-07-161-16/+39
| | | | | | | | Adds the -l/--limit command line option. Limits the number of appointments and/or ToDo items displayed. Signed-off-by: William Pettersson <william.pettersson@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use tabs instead of spaces for indentationLukas Fleischer2013-04-141-541/+566
| | | | | | | | | | | This completes our switch to the Linux kernel coding style. Note that we still use deeply nested constructs at some places which need to be fixed up later. Converted using the `Lindent` script from the Linux kernel code base, along with some manual fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>