From 7ddfcccee0ea83626a3b1a897523e55fbf128774 Mon Sep 17 00:00:00 2001 From: Frederic Culot Date: Sun, 21 Sep 2008 08:05:52 +0000 Subject: import flag and 'i' keybinding added --- src/args.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/args.c') diff --git a/src/args.c b/src/args.c index 0eb0539..4f676d1 100755 --- a/src/args.c +++ b/src/args.c @@ -1,4 +1,4 @@ -/* $calcurse: args.c,v 1.39 2008/09/15 20:40:22 culot Exp $ */ +/* $calcurse: args.c,v 1.40 2008/09/21 08:06:43 culot Exp $ */ /* * Calcurse - text-based organizer @@ -48,7 +48,7 @@ static void usage () { char *arg_usage = - _("Usage: calcurse [-h|-v] [-N] [-an] [-t[num]] [-x[format]]\n" + _("Usage: calcurse [-h|-v] [-N] [-an] [-t[num]] [-i] [-x[format]]\n" " [-d |] [-s[date]] [-r[range]]\n" " [-c | -D]\n"); fputs (arg_usage, stdout); @@ -103,6 +103,8 @@ help_arg () " print events and appointments for or upcoming days and" "\n\texit. To specify both a starting date and a range, use the\n" "\t'--startday' and the '--range' option.\n" + "\n -i , --import \n" + " import the icalendar data contained in . \n" "\n -n, --next\n" " print next appointment within upcoming 24 hours " "and exit. Also given\n\tis the remaining time before this " @@ -573,21 +575,22 @@ parse_args (int argc, char **argv, conf_t *conf) int dflag = 0; /* -d: print appointments for a specified days */ int Dflag = 0; /* -D: specify data directory to use */ int hflag = 0; /* -h: print help text */ + int iflag = 0; /* -i: import data */ int nflag = 0; /* -n: print next appointment */ int Nflag = 0; /* -N: also print note content with apps and todos */ int rflag = 0; /* -r: specify the range of days to consider */ int sflag = 0; /* -s: specify the first day to consider */ int tflag = 0; /* -t: print todo list */ int vflag = 0; /* -v: print version number */ - int xflag = 0; /* -x: export data to iCalendar format */ + int xflag = 0; /* -x: export data */ int tnum = 0, xfmt = 0; int non_interactive = 0, multiple_flag = 0, load_data = 0; int no_file = 1; char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL; - char *datadir = NULL; + char *datadir = NULL, *ifile = NULL; - static char *optstr = "hvnNax::t::d:c:r:s:D:"; + static char *optstr = "hvnNax::t::d:c:r:s:D:i:"; struct option longopts[] = { {"appointment", no_argument, NULL, 'a'}, @@ -595,6 +598,7 @@ parse_args (int argc, char **argv, conf_t *conf) {"day", required_argument, NULL, 'd'}, {"directory", required_argument, NULL, 'D'}, {"help", no_argument, NULL, 'h'}, + {"import", required_argument, NULL, 'i'}, {"next", no_argument, NULL, 'n'}, {"note", no_argument, NULL, 'N'}, {"range", required_argument, NULL, 'r'}, @@ -633,6 +637,12 @@ parse_args (int argc, char **argv, conf_t *conf) case 'h': hflag = 1; break; + case 'i': + iflag = 1; + multiple_flag++; + load_data++; + ifile = optarg; + break; case 'n': nflag = 1; multiple_flag++; @@ -746,9 +756,20 @@ parse_args (int argc, char **argv, conf_t *conf) { io_init (cfile, datadir); no_file = io_check_data_files (); - if (dflag || aflag || nflag || xflag || rflag || sflag) + if (dflag || aflag || nflag || iflag || xflag || rflag || sflag) io_load_app (); } + if (iflag) + { + notify_init_vars (); + vars_init (conf); + custom_load_conf (conf, 0); + io_load_todo (); + io_import_data (IO_MODE_NONINTERACTIVE, IO_IMPORT_ICAL, conf, + ifile); + io_save_cal (IO_MODE_NONINTERACTIVE, conf); + non_interactive = 1; + } if (xflag) { notify_init_vars (); -- cgit v1.2.3-54-g00ecf