From 77c2bdfb8b1b85d4ce01c39288ef557da0a49ac1 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 30 Apr 2019 02:38:01 -0300 Subject: [PATCH] add version subcommand --- README.md | 10 ++++++++-- src/journal/journal.h | 5 +++++ src/journal/main.c | 12 +++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6539da3..c514988 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # lunabot -journal-like util for me +utils for me, as a robot girl -all times are in utc +source is open, data is closed, this is for my own personal use ## depedencies @@ -16,3 +16,9 @@ make # or just remove PREFIX for /usr/local make PREFIX=$HOME/.local install ``` + +## using + +there's currently one utility for me which is journal. + +`journal emotion happy`, etc. list of topics can be found via `journal list`. diff --git a/src/journal/journal.h b/src/journal/journal.h index 1f21989..63ffe95 100644 --- a/src/journal/journal.h +++ b/src/journal/journal.h @@ -2,6 +2,11 @@ #define __JOURNAL_H__ #include +#include + +#define JOURNAL_VERSION "0.0.1" + +#define STREQ(a, b) strcmp(a, b) == 0 FILE *journal_open(char *topic); void journal_write(FILE*, char* message); diff --git a/src/journal/main.c b/src/journal/main.c index cbd0d01..da0d023 100644 --- a/src/journal/main.c +++ b/src/journal/main.c @@ -55,6 +55,8 @@ int main(int argc, char** argv) char *topic = argv[1]; + // topics are injected at compile time + // yes, i'm keeping track of those. don't shame me :))))) const char* topics[TOPICS] = { "emotion", "lust", "orgasm" }; @@ -65,8 +67,14 @@ int main(int argc, char** argv) NULL, NULL, NULL }; + if(STREQ(topic, "version")) + { + printf("lunabot journal v%s\n", JOURNAL_VERSION); + return 0; + } + // list all topics when arg1 is list - if(strcmp(topic, "list") == 0) + if(STREQ(topic, "list")) { for(int i = 0; topics[i] != NULL; i++) printf("%s ", topics[i]); @@ -75,6 +83,8 @@ int main(int argc, char** argv) return 0; } + // go through each topic to find which one we want + // to push the current entry to for(int i = 0; topics[i] != NULL; i++) { const char* cur_topic = topics[i];