add version subcommand

This commit is contained in:
Luna 2019-04-30 02:38:01 -03:00
parent b85aada87c
commit 77c2bdfb8b
3 changed files with 24 additions and 3 deletions

View File

@ -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`.

View File

@ -2,6 +2,11 @@
#define __JOURNAL_H__
#include <stdio.h>
#include <string.h>
#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);

View File

@ -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];