-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use an array to describe the available flags. The flags are no longer hardcoded and the -help section is also generated from that array. This way it will be easier to add more flags in the future. resolves #95
- Loading branch information
1 parent
2183869
commit 7589e1d
Showing
10 changed files
with
172 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <string.h> | ||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
|
||
#include "flag.h" | ||
|
||
struct Flag all_flags[] = { | ||
{ | ||
"help", | ||
"display help text", | ||
false, | ||
false, | ||
}, | ||
{ | ||
"debug", | ||
"print debug statements", | ||
false, | ||
false, | ||
}, | ||
{ | ||
"version", | ||
"display version text", | ||
false, | ||
false, | ||
}, | ||
{ | ||
"h", | ||
"emit .h (header) files", | ||
false, | ||
false, | ||
}, | ||
{ | ||
"avr", | ||
"compile for AVR (default)", | ||
false, | ||
false, | ||
}, | ||
{ | ||
"x86", | ||
"compile for x86-64", | ||
false, | ||
false, | ||
}, | ||
{ | ||
"print-filenames", | ||
"print associated filenames for a .dg file", | ||
false, | ||
false, | ||
}, | ||
}; | ||
|
||
size_t all_flags_count() { | ||
return sizeof(all_flags) / sizeof(struct Flag); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
|
||
#include "flag.h" | ||
|
||
extern struct Flag all_flags[]; | ||
|
||
size_t all_flags_count(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
|
||
struct Flag { | ||
// e.g. -avr | ||
char* name; | ||
|
||
char* description; | ||
|
||
bool has_arg; | ||
|
||
// should be false in the flags array | ||
bool is_set; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.