Add command line argument to run the GC manually
Adds a "-g" option that allows for running the garbage collector for note files manually. This is useful for users that do not use note files at all or rarely edit/remove them. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
711d5dea20
commit
718a6cfee4
@ -103,6 +103,9 @@ appointments can be specified using the *-c* flag.
|
|||||||
Specify the data directory to use. This option is incompatible with -c.
|
Specify the data directory to use. This option is incompatible with -c.
|
||||||
If not specified, the default directory is *~/.calcurse/*.
|
If not specified, the default directory is *~/.calcurse/*.
|
||||||
|
|
||||||
|
*-g*, *--gc*::
|
||||||
|
Run the garbage collector for note files and exit.
|
||||||
|
|
||||||
*-h*, *--help*::
|
*-h*, *--help*::
|
||||||
Print a short help text describing the supported command-line options,
|
Print a short help text describing the supported command-line options,
|
||||||
and exit.
|
and exit.
|
||||||
|
@ -209,6 +209,9 @@ can be specified using the `-c` flag.
|
|||||||
Specify the data directory to use. This option is incompatible with -c.
|
Specify the data directory to use. This option is incompatible with -c.
|
||||||
If not specified, the default directory is `~/.calcurse/`.
|
If not specified, the default directory is `~/.calcurse/`.
|
||||||
|
|
||||||
|
`-g, --gc`::
|
||||||
|
Run the garbage collector for note files and exit.
|
||||||
|
|
||||||
`-h, --help`::
|
`-h, --help`::
|
||||||
Print a short help text describing the supported command-line options,
|
Print a short help text describing the supported command-line options,
|
||||||
and exit.
|
and exit.
|
||||||
|
23
src/args.c
23
src/args.c
@ -52,7 +52,7 @@ static void
|
|||||||
usage ()
|
usage ()
|
||||||
{
|
{
|
||||||
const char *arg_usage =
|
const char *arg_usage =
|
||||||
_("Usage: calcurse [-h|-v] [-N] [-an] [-t[num]] [-i<file>] [-x[format]]\n"
|
_("Usage: calcurse [-g|-h|-v] [-N] [-an] [-t[num]] [-i<file>] [-x[format]]\n"
|
||||||
" [-d <date>|<num>] [-s[date]] [-r[range]]\n"
|
" [-d <date>|<num>] [-s[date]] [-r[range]]\n"
|
||||||
" [-c<file> | -D<dir>] [-S<regex>] [--status]\n");
|
" [-c<file> | -D<dir>] [-S<regex>] [--status]\n");
|
||||||
fputs (arg_usage, stdout);
|
fputs (arg_usage, stdout);
|
||||||
@ -106,6 +106,8 @@ help_arg ()
|
|||||||
" print events and appointments for <date> or <num> upcoming days and"
|
" print events and appointments for <date> or <num> upcoming days and"
|
||||||
"\n\texit. To specify both a starting date and a range, use the\n"
|
"\n\texit. To specify both a starting date and a range, use the\n"
|
||||||
"\t'--startday' and the '--range' option.\n"
|
"\t'--startday' and the '--range' option.\n"
|
||||||
|
"\n -g, --gc\n"
|
||||||
|
" run the garbage collector for note files and exit. \n"
|
||||||
"\n -i <file>, --import <file>\n"
|
"\n -i <file>, --import <file>\n"
|
||||||
" import the icalendar data contained in <file>. \n"
|
" import the icalendar data contained in <file>. \n"
|
||||||
"\n -n, --next\n"
|
"\n -n, --next\n"
|
||||||
@ -686,6 +688,7 @@ parse_args (int argc, char **argv, struct conf *conf)
|
|||||||
int dflag = 0; /* -d: print appointments for a specified days */
|
int dflag = 0; /* -d: print appointments for a specified days */
|
||||||
int Dflag = 0; /* -D: specify data directory to use */
|
int Dflag = 0; /* -D: specify data directory to use */
|
||||||
int hflag = 0; /* -h: print help text */
|
int hflag = 0; /* -h: print help text */
|
||||||
|
int gflag = 0; /* -g: run garbage collector */
|
||||||
int iflag = 0; /* -i: import data */
|
int iflag = 0; /* -i: import data */
|
||||||
int nflag = 0; /* -n: print next appointment */
|
int nflag = 0; /* -n: print next appointment */
|
||||||
int Nflag = 0; /* -N: also print note content with apps and todos */
|
int Nflag = 0; /* -N: also print note content with apps and todos */
|
||||||
@ -708,13 +711,14 @@ parse_args (int argc, char **argv, struct conf *conf)
|
|||||||
STATUS_OPT = CHAR_MAX + 1
|
STATUS_OPT = CHAR_MAX + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *optstr = "hvnNax::t::d:c:r::s::S:D:i:";
|
static char *optstr = "ghvnNax::t::d:c:r::s::S:D:i:";
|
||||||
|
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{"appointment", no_argument, NULL, 'a'},
|
{"appointment", no_argument, NULL, 'a'},
|
||||||
{"calendar", required_argument, NULL, 'c'},
|
{"calendar", required_argument, NULL, 'c'},
|
||||||
{"day", required_argument, NULL, 'd'},
|
{"day", required_argument, NULL, 'd'},
|
||||||
{"directory", required_argument, NULL, 'D'},
|
{"directory", required_argument, NULL, 'D'},
|
||||||
|
{"gc", no_argument, NULL, 'g'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"import", required_argument, NULL, 'i'},
|
{"import", required_argument, NULL, 'i'},
|
||||||
{"next", no_argument, NULL, 'n'},
|
{"next", no_argument, NULL, 'n'},
|
||||||
@ -760,6 +764,9 @@ parse_args (int argc, char **argv, struct conf *conf)
|
|||||||
case 'h':
|
case 'h':
|
||||||
hflag = 1;
|
hflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
gflag = 1;
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
iflag = 1;
|
iflag = 1;
|
||||||
multiple_flag++;
|
multiple_flag++;
|
||||||
@ -894,6 +901,18 @@ parse_args (int argc, char **argv, struct conf *conf)
|
|||||||
status_arg ();
|
status_arg ();
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
}
|
}
|
||||||
|
else if (gflag)
|
||||||
|
{
|
||||||
|
io_init (cfile, datadir);
|
||||||
|
io_check_dir (path_dir, (int *)0);
|
||||||
|
io_check_dir (path_notes, (int *)0);
|
||||||
|
io_check_file (path_apts, (int *)0);
|
||||||
|
io_check_file (path_todo, (int *)0);
|
||||||
|
io_load_app ();
|
||||||
|
io_load_todo ();
|
||||||
|
note_gc ();
|
||||||
|
non_interactive = 1;
|
||||||
|
}
|
||||||
else if (multiple_flag)
|
else if (multiple_flag)
|
||||||
{
|
{
|
||||||
if (load_data)
|
if (load_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user