show help with command line arg -h
This commit is contained in:
parent
411395995c
commit
392eb61e51
31
tools/main.c
31
tools/main.c
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue