From 99425e48e1c53595a9ff4d66c819c6d46c6d2bdc Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Thu, 19 Dec 2024 17:58:21 +0100 Subject: added help flag -h --- README.md | 15 ++++++++------- main.c | 4 +++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9ec3359..dd9b0e8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # myal - My Anime Library -My Anime Library is cli-tool to manage an anime watchlist, written in C. +My Anime Library is a cli-tool written in C to manage an anime watchlist. I used to track which anime I have watched and what episode I'm on by writing in a text file, which got annoying after a while. This is why I created a simple program to quickly search and change a @@ -9,24 +9,25 @@ csv file. Is it a complete overkill to write this in C? Yes Could this have been a simple bash script? Definitely -But why not? +But why not? I wanted some practice with C, so if you see any glaring errors or +unsafe code feel free to point it out and roast me. This cli-tool works with csv files in the format name,episode -For example: +For example: Samurai Champloo,14 Bakemonogatari,done Steins; Gate,1 and so on. The episode is actually stored as a string, so you can put "done" or -"abandoned" or anything else you want in there. Allows for a maximum length of -11. +"abandoned" or anything else you want in there. The string allows for a maximum +length of 11. -You need to set your filepath in the main.c, but everything else should work -out of the box. +You need to set the filepath to you csv in the main.c, but everything else +should work out of the box. The Makefile uses clang, but you can change it to gcc in the second line. Or you could simply do diff --git a/main.c b/main.c index 129aa04..b37cd63 100644 --- a/main.c +++ b/main.c @@ -26,6 +26,7 @@ void print_help() printf(" -s Search for a specific anime by name \n"); printf(" -a Append new anime and episode to file \n"); printf(" -e Edit the episode number of an anime \n"); + printf(" -h Print this help menu \n"); printf("\n"); } @@ -204,12 +205,13 @@ int main(int argc, char **argv) { mode_e mode; int opt; - while ((opt = getopt(argc, argv, "msae")) != -1) { + while ((opt = getopt(argc, argv, "msaeh")) != -1) { switch (opt) { case 'm': mode = MATCH_MODE; break; case 's': mode = SEARCH_MODE; break; case 'a': mode = APPEND_MODE; break; case 'e': mode = EDIT_MODE; break; + case 'h': print_help(); exit(EXIT_SUCCESS); default: print_help(); exit(EXIT_FAILURE); -- cgit v1.2.3