Add disassemblre group option

This commit is contained in:
hiperiondev
2023-08-28 23:46:02 -03:00
parent 6be29ed8c5
commit a9ccd65da1
5 changed files with 315 additions and 176 deletions

View File

@@ -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;
}