50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
#include <time.h>
|
|
#include <stdlib.h>
|
|
#include "wte.h"
|
|
|
|
static size_t get_entry_count()
|
|
{
|
|
size_t count = 0;
|
|
count++;
|
|
return count;
|
|
}
|
|
|
|
static int make_suggestion()
|
|
{
|
|
int ret = 0;
|
|
srandom(time(NULL)); // seed random with current time
|
|
size_t count = get_entry_count();
|
|
if (count) {
|
|
size_t choice = random() % count;
|
|
printf("choice: %lu", choice);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int main(const int argc, const char **argv)
|
|
{
|
|
int ret = 1;
|
|
if (2 == argc && '-' == argv[1][0]) {
|
|
if ('h' == argv[1][1] && '\0' == argv[1][2]) {
|
|
printf("wte - what to eat\na simple decision making tool for food\nuse without options\n");
|
|
} else if ('a' == argv[1][1] && '\0' == argv[1][2]) {
|
|
ret = insert_choice();
|
|
} else if ('d' == argv[1][1] && '\0' == argv[1][2]) {
|
|
ret = remove_choice();
|
|
} else if ('c' == argv[1][1] && '\0' == argv[1][2]) {
|
|
ret = create_data_dir();
|
|
} else if ('x' == argv[1][1] && '\0' == argv[1][2]) {
|
|
ret = remove_data_dir();
|
|
} else {
|
|
printf("unrecognized option, try %s -h\n", *argv);
|
|
}
|
|
goto exit_main;
|
|
}
|
|
|
|
if (make_suggestion()) {
|
|
ret = 0;
|
|
}
|
|
|
|
exit_main:
|
|
return ret;
|
|
}
|