summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadna Vigo <arivigodr@gmail.com>2020-11-18 00:46:52 +0100
committerAriadna Vigo <arivigodr@gmail.com>2020-11-18 00:46:52 +0100
commitbbfbf45d7258a1e9d2c33809da22f1bc45217288 (patch)
tree4418a0b7f992745e89f22219da59d6d88d9874e9
parent00dc312e49c5658370957b15a77332fb73242845 (diff)
Implemented a way to force expiration of files
-rw-r--r--cras.18
-rw-r--r--cras.c27
2 files changed, 33 insertions, 2 deletions
diff --git a/cras.1 b/cras.1
index 4fd9862..8c2d830 100644
--- a/cras.1
+++ b/cras.1
@@ -5,7 +5,7 @@ cras - The Anti-Procrastination Tool
.SH SYNOPSIS
.PP
.B cras
-.RB [ \-anov ]
+.RB [ \-ainov ]
.RB [ \-dtT
.IR num ]
.I file
@@ -21,6 +21,10 @@ Append new tasks to
.I file.
(Be aware that this doesn't update the expiration date.)
.TP
+.B \-i
+Force expiration of
+.I file.
+.TP
.B \-n
Create new
.I file,
@@ -57,6 +61,8 @@ date, which under the default configuration is 24 hours after originally saving
it. Use -t to mark a task as done and -T to mark it back as pending.
.PP
You may delete tasks by using the -d option followed by its identifying number.
+If you want to set the whole file as already expired, you may do so by using
+the -i option.
.PP
Running cras with no options outputs the task list. For a summary, use the -o
flag; this short-form output is suitable for printing to WM status bars.
diff --git a/cras.c b/cras.c
index 2f56d05..9874829 100644
--- a/cras.c
+++ b/cras.c
@@ -24,6 +24,7 @@ enum {
enum {
DEF_MODE,
APP_MODE,
+ INVAL_MODE,
NEW_MODE,
OUT_MODE,
DLT_MODE,
@@ -45,6 +46,7 @@ static void input_mode(const char *crasfile, int append);
static void output_mode(const char *crasfile, int mode);
static void delete_mode(const char *crasfile, const char *id);
static void mark_list_mode(const char *crasfile, const char *id, int value);
+static void inval_mode(const char *crasfile);
static void
die(const char *fmt, ...)
@@ -214,7 +216,7 @@ parse_tasknum(const char *id)
static void
usage(void)
{
- die("usage: cras [-anov] [-dtT num] file");
+ die("usage: cras [-ainov] [-dtT num] file");
}
static void
@@ -308,6 +310,21 @@ mark_list_mode(const char *crasfile, const char *id, int value)
task_lst_cleanup(&list);
}
+static void
+inval_mode(const char *crasfile)
+{
+ TaskLst list;
+
+ task_lst_init(&list);
+ read_crasfile(&list, crasfile);
+
+ task_lst_set_expiration(&list, 0);
+
+ write_crasfile(crasfile, list);
+
+ task_lst_cleanup(&list);
+}
+
int
main(int argc, char *argv[])
{
@@ -321,6 +338,11 @@ main(int argc, char *argv[])
usage();
mode = APP_MODE;
break;
+ case 'i':
+ if (mode != DEF_MODE)
+ usage();
+ mode = INVAL_MODE;
+ break;
case 'n':
if (mode != DEF_MODE)
usage();
@@ -366,6 +388,9 @@ main(int argc, char *argv[])
case APP_MODE:
input_mode(argv[0], 1);
return 0;
+ case INVAL_MODE:
+ inval_mode(argv[0]);
+ return 0;
case NEW_MODE:
input_mode(argv[0], 0);
return 0;