'-t' flag now takes a priority number for argument
This commit is contained in:
parent
42ae927c78
commit
55589fa5ef
54
src/args.c
54
src/args.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: args.c,v 1.7 2006/09/16 09:08:21 culot Exp $ */
|
/* $calcurse: args.c,v 1.8 2006/10/16 15:48:30 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -58,9 +58,9 @@ int parse_args(int argc, char **argv, int colr)
|
|||||||
int hflag = 0, tflag = 0, nflag = 0;
|
int hflag = 0, tflag = 0, nflag = 0;
|
||||||
int non_interactive = 0, multiple_flag = 0, load_data = 0;
|
int non_interactive = 0, multiple_flag = 0, load_data = 0;
|
||||||
int no_file = 1;
|
int no_file = 1;
|
||||||
char *ddate = "", *cfile = NULL;
|
char *ddate = "", *cfile = NULL, *tnum = NULL;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "hvntad:c:")) != -1) {
|
while ((ch = getopt(argc, argv, "hvnat:d:c:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
aflag = 1;
|
aflag = 1;
|
||||||
@ -92,6 +92,7 @@ int parse_args(int argc, char **argv, int colr)
|
|||||||
multiple_flag++;
|
multiple_flag++;
|
||||||
load_data++;
|
load_data++;
|
||||||
add_line = 1;
|
add_line = 1;
|
||||||
|
tnum = optarg;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
vflag = 1;
|
vflag = 1;
|
||||||
@ -108,7 +109,7 @@ int parse_args(int argc, char **argv, int colr)
|
|||||||
if (argc >= 1) { /* incorrect arguments */
|
if (argc >= 1) { /* incorrect arguments */
|
||||||
usage();
|
usage();
|
||||||
usage_try();
|
usage_try();
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
if (unknown_flag) {
|
if (unknown_flag) {
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
@ -126,7 +127,7 @@ int parse_args(int argc, char **argv, int colr)
|
|||||||
load_app(colr);
|
load_app(colr);
|
||||||
}
|
}
|
||||||
if (tflag) {
|
if (tflag) {
|
||||||
todo_arg(colr);
|
todo_arg(atoi(tnum), colr);
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
}
|
}
|
||||||
if (nflag) {
|
if (nflag) {
|
||||||
@ -183,7 +184,12 @@ void help_arg()
|
|||||||
"'mm/dd/yyyy' or 'n'.\n"
|
"'mm/dd/yyyy' or 'n'.\n"
|
||||||
" -n print next appointment within upcoming 24 hours "
|
" -n print next appointment within upcoming 24 hours "
|
||||||
"and exit.\n"
|
"and exit.\n"
|
||||||
" -t print todo list and exit.\n"
|
" -t [num] print todo list and exit. "
|
||||||
|
"If the optional number [num] is \n"
|
||||||
|
"\t\tgiven, then only the todos having a priority equal to [num]\n"
|
||||||
|
"\t\twill be returned.\n"
|
||||||
|
"\t\tnote: the priority number must be between 1 (highest) and\n"
|
||||||
|
"\t\t9 (lowest)\n"
|
||||||
"\nFor more information, type '?' from within Calcurse, "
|
"\nFor more information, type '?' from within Calcurse, "
|
||||||
"or read the manpage.\n"
|
"or read the manpage.\n"
|
||||||
"Mail bug reports and suggestions to <calcurse@culot.org>.\n");
|
"Mail bug reports and suggestions to <calcurse@culot.org>.\n");
|
||||||
@ -195,21 +201,33 @@ void help_arg()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print todo list and exit.
|
* Print todo list and exit. If a priority number is given (say not equal to
|
||||||
|
* zero), then only todo items that have this priority will be displayed.
|
||||||
*/
|
*/
|
||||||
void todo_arg(int colr)
|
int todo_arg(int priority, int colr)
|
||||||
{
|
{
|
||||||
struct todo_s *i;
|
struct todo_s *i;
|
||||||
int nb_tod;
|
int nb_tod, title = 1;
|
||||||
char priority[MAX_LENGTH] = "";
|
char priority_str[MAX_LENGTH] = "";
|
||||||
|
|
||||||
nb_tod = load_todo(colr);
|
if (priority >= 9 || priority <= 0) {
|
||||||
fputs(_("to do:\n"),stdout);
|
usage();
|
||||||
for (i = todolist; i != 0; i = i->next) {
|
usage_try();
|
||||||
sprintf(priority, "%d. ", i->id);
|
return EXIT_FAILURE;
|
||||||
fputs(priority,stdout);
|
} else {
|
||||||
fputs(i->mesg,stdout);
|
nb_tod = load_todo(colr);
|
||||||
fputs("\n",stdout);
|
for (i = todolist; i != 0; i = i->next) {
|
||||||
|
if (priority == 0 || i->id == priority) {
|
||||||
|
if (title) {
|
||||||
|
fputs(_("to do:\n"),stdout);
|
||||||
|
title = 0;
|
||||||
|
}
|
||||||
|
sprintf(priority_str, "%d. ", i->id);
|
||||||
|
fputs(priority_str,stdout);
|
||||||
|
fputs(i->mesg,stdout);
|
||||||
|
fputs("\n",stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +481,7 @@ void arg_print_date(long date)
|
|||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
char *arg_usage =
|
char *arg_usage =
|
||||||
_("Usage: calcurse [-h | -v] [-ant] [-d date|num] [-c file]\n");
|
_("Usage: calcurse [-h | -v] [-an] [-t [num]] [-d date|num] [-c file]\n");
|
||||||
|
|
||||||
fputs(arg_usage, stdout);
|
fputs(arg_usage, stdout);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user