aboutsummaryrefslogtreecommitdiffstats
path: root/src/args.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-02-11 18:22:05 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-02-11 18:33:57 +0100
commit07954626c6925f22e4d59b6d68f0947d4e54b8b9 (patch)
treee691a26dbb8ada6f708f08c529c1e8af826d61e2 /src/args.c
parentfe0621bafd21acaf9909cb2f8ea65fa56560faed (diff)
downloadcalcurse-07954626c6925f22e4d59b6d68f0947d4e54b8b9.tar.gz
calcurse-07954626c6925f22e4d59b6d68f0947d4e54b8b9.zip
Support format strings when dumping imported items
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>
Diffstat (limited to 'src/args.c')
-rw-r--r--src/args.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/args.c b/src/args.c
index 4743067..3834f4a 100644
--- a/src/args.c
+++ b/src/args.c
@@ -70,7 +70,7 @@ enum {
OPT_FMT_EV,
OPT_FMT_REV,
OPT_FMT_TODO,
- OPT_LIST_IMPORTED,
+ OPT_DUMP_IMPORTED,
OPT_EXPORT_UID,
OPT_READ_ONLY,
OPT_STATUS,
@@ -402,7 +402,7 @@ int parse_args(int argc, char **argv)
const char *fmt_todo = NULL;
/* Import and export parameters */
int xfmt = IO_EXPORT_ICAL;
- int list_imported = 0, export_uid = 0;
+ int dump_imported = 0, export_uid = 0;
/* Data file locations */
const char *cfile = NULL, *datadir = NULL, *ifile = NULL;
@@ -459,7 +459,7 @@ int parse_args(int argc, char **argv)
{"format-recur-event", required_argument, NULL, OPT_FMT_REV},
{"format-todo", required_argument, NULL, OPT_FMT_TODO},
{"export-uid", no_argument, NULL, OPT_EXPORT_UID},
- {"list-imported", no_argument, NULL, OPT_LIST_IMPORTED},
+ {"dump-imported", no_argument, NULL, OPT_DUMP_IMPORTED},
{"read-only", no_argument, NULL, OPT_READ_ONLY},
{"status", no_argument, NULL, OPT_STATUS},
{"daemon", no_argument, NULL, OPT_DAEMON},
@@ -669,8 +669,8 @@ int parse_args(int argc, char **argv)
case OPT_FMT_TODO:
fmt_todo = optarg;
break;
- case OPT_LIST_IMPORTED:
- list_imported = 1;
+ case OPT_DUMP_IMPORTED:
+ dump_imported = 1;
break;
case OPT_EXPORT_UID:
export_uid = 1;
@@ -776,7 +776,24 @@ int parse_args(int argc, char **argv)
/* Get default pager in case we need to show a log file. */
vars_init();
io_load_data(NULL);
- io_import_data(IO_IMPORT_ICAL, ifile, list_imported);
+ if (dump_imported) {
+ /*
+ * Use default values for non-specified format strings.
+ */
+ fmt_apt = fmt_apt ? fmt_apt : "%(raw)";
+ fmt_rapt = fmt_rapt ? fmt_rapt : "%(raw)";
+ fmt_ev = fmt_ev ? fmt_ev : "%(raw)";
+ fmt_rev = fmt_rev ? fmt_rev : "%(raw)";
+ fmt_todo = fmt_todo ? fmt_todo : "%(raw)";
+ } else {
+ /*
+ * Do not dump items, unset format strings explicitly.
+ */
+ 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);
io_save_apts(path_apts);
io_save_todo(path_todo);
} else if (export) {