diff --git a/src/main.c b/src/main.c index 4b711d2..6e71b46 100644 --- a/src/main.c +++ b/src/main.c @@ -10,6 +10,23 @@ void die(char *s) { fprintf(stderr, "fatal: %s\n", s); exit(1); } + +void usage(void) { + printf( + "cards: A terminal flashcard program written in C using ncurses.\n" + "Usage:\n" + " cards [filename]\n" + " Read cards from filename. Filename must be a tab separated value file\n" + " containing exactly two fields. The first field should contain the text for\n" + " the \"front\" of the card. The second field should contain the text for the\n" + " back. Each line is read as a separate card. Note that it must be delimited\n" + " by hard tabs (ascii 9), NOT spaces.\n" + " cards --help\n" + " Display this help message.\n" + ); + exit(0); +} + char *fgetl(FILE *stream) { size_t s_sz = 1; // +1 for null byte char *s = NULL; char c; @@ -42,7 +59,9 @@ int main(int argc, char **argv) { char k = '\0', *help_message; if (argc < 2) - die("filename required"); + die("arg required"); + if (!strcmp(argv[1], "--help")) + usage(); cards = card_parse_csv(argv[1], &cards_ct);