show help with command line arg -h

This commit is contained in:
Yuichi Nishiwaki 2013-10-24 19:06:31 +09:00
parent 411395995c
commit 392eb61e51
1 changed files with 31 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include <unistd.h>
#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);