diff --git a/tools/main.c b/tools/main.c index f5484550..0cbf46ff 100644 --- a/tools/main.c +++ b/tools/main.c @@ -1,4 +1,5 @@ #include +#include #include "picrin.h" @@ -12,6 +13,34 @@ #define CODE_MAX_LENGTH 1024 #define LINE_MAX_LENGTH 256 +void +print_help(void) +{ + const char *help = + "picrin scheme\n" + "\n" + "Usage: picrin [options]\n" + "\n" + "Options:\n" + " -h show this help"; + + puts(help); +} + +void +parse_opt(int argc, char *argv[]) +{ + int r; + + while (~(r = getopt(argc, argv, "h"))) { + switch (r) { + case 'h': + print_help(); + exit(0); + } + } +} + int main(int argc, char *argv[], char **envp) { @@ -28,6 +57,8 @@ main(int argc, char *argv[], char **envp) int char_index; #endif + parse_opt(argc, argv); + pic = pic_open(argc, argv, envp); ai = pic_gc_arena_preserve(pic);