argument parsing

This commit is contained in:
Kied Llaentenn 2019-12-12 22:39:35 -05:00
parent a5c3fe1992
commit 6d2b6ffcca
3 changed files with 23 additions and 6 deletions

5
args.h
View File

@ -19,10 +19,7 @@
extern char *argv0;
typedef struct Options {
bool perf_opt1;
bool perf_opt2;
bool perf_opt3;
bool verbose;
bool stub; // no real options... yet
} Options;
/* use main(int argc, char *argv[]) */

23
main.c
View File

@ -7,13 +7,32 @@
#include "termbox.h"
#include "args.h"
#define VERSION "0.1.0"
// argument parsing (args.h)
char *argv0;
struct Options *opts;
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
tb_init();
tb_select_output_mode(TB_OUTPUT_NORMAL);
@ -40,7 +59,7 @@ main ( void )
tb_shutdown();
// cleanup framebuffer
free(buf.tmp_buf);
free(buf.buf);
return 0;
}

View File

@ -1,5 +1,6 @@
#ifndef OUTP_H
#define OUTP_H
#include <stdio.h>
#define PRINT(...) fprintf(stderr, __VA_ARGS__);