aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-02-13 18:23:41 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-02-13 18:23:41 +0100
commit6dc570e657d6cac10aa2af9c259df6c2cdb4ae02 (patch)
treed3fa66b4137f2f299da6dd7c86fe0e602e35114c
parent37a60e1e66abfacb8f3f3b996b83c593b093d723 (diff)
downloadwcal-6dc570e657d6cac10aa2af9c259df6c2cdb4ae02.tar.gz
wcal-6dc570e657d6cac10aa2af9c259df6c2cdb4ae02.tar.xz
wcal-6dc570e657d6cac10aa2af9c259df6c2cdb4ae02.zip
add usage, wcal takes no argumentsv0.1
-rw-r--r--wcal.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/wcal.c b/wcal.c
index fefc9e3..3293f42 100644
--- a/wcal.c
+++ b/wcal.c
@@ -109,6 +109,13 @@ parse_isodate(char *optarg, int *y, int *m, int *d)
}
}
+void
+usage()
+{
+ fprintf(stderr, "Usage: wcal [-13yci] [-d YYYY[-MM[-DD]]]\n");
+ exit(1);
+}
+
int
main(int argc, char *argv[])
{
@@ -135,9 +142,12 @@ main(int argc, char *argv[])
case 'y': flagy = 1; break;
case 'i': flagi = 1; break;
case 'd': parse_isodate(optarg, &y, &m, &d); break;
- case '?': exit(1);
+ case '?': usage();
}
+ if (argc > optind)
+ usage();
+
long today = ymd2jd(y, m, d);
jd2ymdwi(today, &y, &m, &d, &cw, &ci, &cg);