mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Add disassemblre group option
This commit is contained in:
@@ -4,36 +4,42 @@
|
||||
#include "disassembler.h"
|
||||
|
||||
static struct cag_option options[] = {
|
||||
{
|
||||
.identifier = 'a',
|
||||
.access_letters = "a",
|
||||
.access_name = NULL,
|
||||
.value_name = NULL,
|
||||
.description = "Alternate format"
|
||||
}, {
|
||||
.identifier = 'h',
|
||||
.access_letters = "h",
|
||||
.access_name = "help",
|
||||
.description = "Shows the command help"
|
||||
}
|
||||
};
|
||||
|
||||
struct options {
|
||||
bool alternate_flag;
|
||||
{
|
||||
.identifier = 'a',
|
||||
.access_letters = "a",
|
||||
.access_name = NULL,
|
||||
.value_name = NULL,
|
||||
.description = "Alternate format"
|
||||
}, {
|
||||
.identifier = 'g',
|
||||
.access_letters = "g",
|
||||
.access_name = NULL,
|
||||
.value_name = NULL,
|
||||
.description = "Group literals with functions"
|
||||
}, {
|
||||
.identifier = 'h',
|
||||
.access_letters = "h",
|
||||
.access_name = "help",
|
||||
.description = "Shows the command help"
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char identifier;
|
||||
cag_option_context context;
|
||||
struct options config = { false };
|
||||
options_t config = { false, false };
|
||||
|
||||
cag_option_prepare(&context, options, CAG_ARRAY_SIZE(options), argc, argv);
|
||||
while (cag_option_fetch(&context)) {
|
||||
identifier = cag_option_get(&context);
|
||||
switch (identifier) {
|
||||
case 'a':
|
||||
config.alternate_flag = true;
|
||||
config.alt_format_flag = true;
|
||||
break;
|
||||
case 'g':
|
||||
config.group_flag = true;
|
||||
config.alt_format_flag = true;
|
||||
break;
|
||||
case 'h':
|
||||
printf("Usage: disassembler [OPTION] file\n");
|
||||
cag_option_print(options, CAG_ARRAY_SIZE(options), stdout);
|
||||
@@ -41,6 +47,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
disassemble(argv[context.index], config.alternate_flag);
|
||||
disassemble(argv[context.index], config);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user