mirror of
https://github.com/kiedtl/fire.git
synced 2024-11-16 04:56:38 +00:00
argument parsing
This commit is contained in:
parent
a5c3fe1992
commit
6d2b6ffcca
5
args.h
5
args.h
@ -19,10 +19,7 @@
|
|||||||
extern char *argv0;
|
extern char *argv0;
|
||||||
|
|
||||||
typedef struct Options {
|
typedef struct Options {
|
||||||
bool perf_opt1;
|
bool stub; // no real options... yet
|
||||||
bool perf_opt2;
|
|
||||||
bool perf_opt3;
|
|
||||||
bool verbose;
|
|
||||||
} Options;
|
} Options;
|
||||||
|
|
||||||
/* use main(int argc, char *argv[]) */
|
/* use main(int argc, char *argv[]) */
|
||||||
|
23
main.c
23
main.c
@ -7,13 +7,32 @@
|
|||||||
#include "termbox.h"
|
#include "termbox.h"
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
|
|
||||||
|
#define VERSION "0.1.0"
|
||||||
|
|
||||||
// argument parsing (args.h)
|
// argument parsing (args.h)
|
||||||
char *argv0;
|
char *argv0;
|
||||||
struct Options *opts;
|
struct Options *opts;
|
||||||
|
|
||||||
int
|
int
|
||||||
main ( void )
|
main ( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
// argument parsing
|
||||||
|
argv0 = argv[0];
|
||||||
|
|
||||||
|
ARGBEGIN {
|
||||||
|
case 'V':
|
||||||
|
PRINT("%s %s\n", argv0, VERSION);
|
||||||
|
exit(0);
|
||||||
|
case 'h':
|
||||||
|
default:
|
||||||
|
PRINT("fire %s\n(c) Kied Llaentenn and contributors\n", VERSION);
|
||||||
|
PRINT("https://github.com/lptstr/fire\n");
|
||||||
|
PRINT("\nUSAGE:\n\t$ fire\n\n");
|
||||||
|
PRINT("OPTIONS:\n\t-V\tshow version and exit.\n");
|
||||||
|
PRINT("\t-h\tshow this help message and exit.\n\n");
|
||||||
|
exit(1);
|
||||||
|
} ARGEND
|
||||||
|
|
||||||
// initialize termbox
|
// initialize termbox
|
||||||
tb_init();
|
tb_init();
|
||||||
tb_select_output_mode(TB_OUTPUT_NORMAL);
|
tb_select_output_mode(TB_OUTPUT_NORMAL);
|
||||||
@ -40,7 +59,7 @@ main ( void )
|
|||||||
tb_shutdown();
|
tb_shutdown();
|
||||||
|
|
||||||
// cleanup framebuffer
|
// cleanup framebuffer
|
||||||
free(buf.tmp_buf);
|
free(buf.buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user