Add option to specify the configuration file used
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>
This commit is contained in:
parent
574156be7c
commit
407d5abd23
14
src/args.c
14
src/args.c
@ -83,7 +83,7 @@ enum {
|
|||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("%s\n", _("usage: calcurse [--daemon|-F|-G|-g|-i<file>|-Q|--status|-x[<format>]]\n"
|
printf("%s\n", _("usage: calcurse [--daemon|-F|-G|-g|-i<file>|-Q|--status|-x[<format>]]\n"
|
||||||
" [-c<file>] [-D<path>] [-h] [-q] [--read-only] [-v]\n"
|
" [-c<file>] [-C<file] [-D<path>] [-h] [-q] [--read-only] [-v]\n"
|
||||||
" [--filter-*] [--format-*]"));
|
" [--filter-*] [--format-*]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +120,7 @@ static void help_arg(void)
|
|||||||
putchar('\n');
|
putchar('\n');
|
||||||
printf("%s\n", _("Miscellaneous:"));
|
printf("%s\n", _("Miscellaneous:"));
|
||||||
printf("%s\n", _(" -c, --calendar <file> Specify the calendar data file to use"));
|
printf("%s\n", _(" -c, --calendar <file> Specify the calendar data file to use"));
|
||||||
|
printf("%s\n", _(" -C, --conf <file> Specify the configuration file to use"));
|
||||||
printf("%s\n", _(" --daemon Run notification daemon in the background"));
|
printf("%s\n", _(" --daemon Run notification daemon in the background"));
|
||||||
printf("%s\n", _(" -D, --directory <path> Specify the data directory to use"));
|
printf("%s\n", _(" -D, --directory <path> Specify the data directory to use"));
|
||||||
printf("%s\n", _(" -g, --gc Run the garbage collector and exit"));
|
printf("%s\n", _(" -g, --gc Run the garbage collector and exit"));
|
||||||
@ -404,17 +405,19 @@ int parse_args(int argc, char **argv)
|
|||||||
int xfmt = IO_EXPORT_ICAL;
|
int xfmt = IO_EXPORT_ICAL;
|
||||||
int dump_imported = 0, export_uid = 0;
|
int dump_imported = 0, export_uid = 0;
|
||||||
/* Data file locations */
|
/* Data file locations */
|
||||||
const char *cfile = NULL, *datadir = NULL, *ifile = NULL;
|
const char *datadir = NULL;
|
||||||
|
const char *cfile = NULL, *ifile = NULL, *conffile = NULL;
|
||||||
|
|
||||||
int non_interactive = 1;
|
int non_interactive = 1;
|
||||||
int ch;
|
int ch;
|
||||||
regex_t reg;
|
regex_t reg;
|
||||||
|
|
||||||
static const char *optstr = "FgGhvnNax::t::d:c:r::s::S:D:i:l:qQ";
|
static const char *optstr = "FgGhvnNax::t::C:d:c:r::s::S:D:i:l:qQ";
|
||||||
|
|
||||||
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'},
|
||||||
|
{"conf", required_argument, NULL, 'C'},
|
||||||
{"day", required_argument, NULL, 'd'},
|
{"day", required_argument, NULL, 'd'},
|
||||||
{"directory", required_argument, NULL, 'D'},
|
{"directory", required_argument, NULL, 'D'},
|
||||||
{"filter", no_argument, NULL, 'F'},
|
{"filter", no_argument, NULL, 'F'},
|
||||||
@ -475,6 +478,9 @@ int parse_args(int argc, char **argv)
|
|||||||
case 'c':
|
case 'c':
|
||||||
cfile = optarg;
|
cfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
conffile = optarg;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if (is_all_digit(optarg) ||
|
if (is_all_digit(optarg) ||
|
||||||
(*optarg == '-' && is_all_digit(optarg + 1))) {
|
(*optarg == '-' && is_all_digit(optarg + 1))) {
|
||||||
@ -720,7 +726,7 @@ int parse_args(int argc, char **argv)
|
|||||||
else if (range < 0)
|
else if (range < 0)
|
||||||
from = date_sec_change(to, 0, range);
|
from = date_sec_change(to, 0, range);
|
||||||
|
|
||||||
io_init(cfile, datadir);
|
io_init(cfile, datadir, conffile);
|
||||||
io_check_dir(path_dir);
|
io_check_dir(path_dir);
|
||||||
io_check_dir(path_notes);
|
io_check_dir(path_notes);
|
||||||
|
|
||||||
|
@ -841,7 +841,7 @@ void ical_export_data(FILE *, int);
|
|||||||
|
|
||||||
/* io.c */
|
/* io.c */
|
||||||
unsigned io_fprintln(const char *, const char *, ...);
|
unsigned io_fprintln(const char *, const char *, ...);
|
||||||
void io_init(const char *, const char *);
|
void io_init(const char *, const char *, const char *);
|
||||||
void io_extract_data(char *, const char *, int);
|
void io_extract_data(char *, const char *, int);
|
||||||
void io_dump_apts(const char *, const char *, const char *, const char *);
|
void io_dump_apts(const char *, const char *, const char *, const char *);
|
||||||
unsigned io_save_apts(const char *);
|
unsigned io_save_apts(const char *);
|
||||||
|
13
src/io.c
13
src/io.c
@ -226,16 +226,20 @@ unsigned io_fprintln(const char *fname, const char *fmt, ...)
|
|||||||
* one (~/.calcurse/apts) is taken. If the one given does not exist, it
|
* one (~/.calcurse/apts) is taken. If the one given does not exist, it
|
||||||
* is created.
|
* is created.
|
||||||
* The datadir argument can be use to specify an alternative data root dir.
|
* The datadir argument can be use to specify an alternative data root dir.
|
||||||
|
* The conffile argument can be use to specify an alternative configuration file.
|
||||||
*/
|
*/
|
||||||
void io_init(const char *cfile, const char *datadir)
|
void io_init(const char *cfile, const char *datadir, const char *conffile)
|
||||||
{
|
{
|
||||||
const char *home;
|
const char *home;
|
||||||
|
|
||||||
if (datadir != NULL) {
|
if (datadir != NULL) {
|
||||||
home = datadir;
|
home = datadir;
|
||||||
snprintf(path_dir, BUFSIZ, "%s", home);
|
snprintf(path_dir, BUFSIZ, "%s", home);
|
||||||
snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH_NAME, home);
|
if (conffile)
|
||||||
|
snprintf(path_conf, BUFSIZ, "%s", conffile);
|
||||||
|
else
|
||||||
snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH_NAME, home);
|
snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH_NAME, home);
|
||||||
|
snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH_NAME, home);
|
||||||
snprintf(path_notes, BUFSIZ, "%s/" NOTES_DIR_NAME, home);
|
snprintf(path_notes, BUFSIZ, "%s/" NOTES_DIR_NAME, home);
|
||||||
snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH_NAME, home);
|
snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH_NAME, home);
|
||||||
snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH_NAME, home);
|
snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH_NAME, home);
|
||||||
@ -248,9 +252,12 @@ void io_init(const char *cfile, const char *datadir)
|
|||||||
if (home == NULL) {
|
if (home == NULL) {
|
||||||
home = ".";
|
home = ".";
|
||||||
}
|
}
|
||||||
|
if (conffile)
|
||||||
|
snprintf(path_conf, BUFSIZ, "%s", conffile);
|
||||||
|
else
|
||||||
|
snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH, home);
|
||||||
snprintf(path_dir, BUFSIZ, "%s/" DIR_NAME, home);
|
snprintf(path_dir, BUFSIZ, "%s/" DIR_NAME, home);
|
||||||
snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH, home);
|
snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH, home);
|
||||||
snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH, home);
|
|
||||||
snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH, home);
|
snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH, home);
|
||||||
snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH, home);
|
snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH, home);
|
||||||
snprintf(path_dpid, BUFSIZ, "%s/" DPID_PATH, home);
|
snprintf(path_dpid, BUFSIZ, "%s/" DPID_PATH, home);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user