fix(kernel): options were not properly parsed

Had to set the context.index to 0 because here argv[0] is not the program name.

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-03-27 01:07:27 +00:00
parent 9304cafe0c
commit a7f754c5e8
Signed by: enderice2
GPG Key ID: FEB6B8A8507BA62E

View File

@ -126,16 +126,14 @@ void ParseConfig(char *ConfigString, KernelConfig *ModConfig)
debug("argc = %d", argc); debug("argc = %d", argc);
#endif #endif
char identifier;
const char *value;
cag_option_context context; cag_option_context context;
cag_option_init(&context, ConfigOptions, CAG_ARRAY_SIZE(ConfigOptions), argc, argv);
context.index = 0; /* We don't have the standard argv[0] == <program name> */
cag_option_prepare(&context, ConfigOptions, const char *value;
CAG_ARRAY_SIZE(ConfigOptions), argc, argv);
while (cag_option_fetch(&context)) while (cag_option_fetch(&context))
{ {
identifier = cag_option_get(&context); char identifier = cag_option_get_identifier(&context);
switch (identifier) switch (identifier)
{ {
case 'a': case 'a':
@ -263,12 +261,11 @@ void ParseConfig(char *ConfigString, KernelConfig *ModConfig)
KPrint("\x1b[1;31;41mSystem Halted."); KPrint("\x1b[1;31;41mSystem Halted.");
CPU::Stop(); CPU::Stop();
} }
case '?':
default: default:
{ cag_option_print_error(&context, stdout);
KPrint("\x1b[31mUnknown option: %c", identifier);
break; break;
} }
}
} }
debug("Config loaded"); debug("Config loaded");
} }