Parse commandline strings, move away from old env vars
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 2m6s
Build documentation / build-and-deploy (push) Successful in 1m18s

This commit is contained in:
2026-04-28 22:45:31 +02:00
parent 9fbe23024c
commit fbf067d418
15 changed files with 265 additions and 185 deletions

View File

@@ -1,3 +1,4 @@
#include <cmdline_parser.h>
#include <device_info.h>
#include <devices.h>
#include <malloc.h>
@@ -7,6 +8,13 @@
#include <string.h>
#include <system.h>
static bool cmdline_list_all = false;
static struct cmdline_opt cmdline_opts[] = {
CMDLINE_OPT("la", "list-all", CMDLINE_OPT_VALUE_BOOL, false, &cmdline_list_all),
CMDLINE_END(),
};
static const char* device_types_str[] = {
[DEVICE_TYPE_DEBUGCONSOLE] = "Debug console", [DEVICE_TYPE_TERMINAL] = "System terminal",
[DEVICE_TYPE_KEYBOARD] = "Keyboard", [DEVICE_TYPE_DRIVE] = "Drive",
@@ -28,21 +36,12 @@ static void list_all_devices(void) {
}
void app_main(void) {
char commandbuf[32];
memset(commandbuf, 0, sizeof(commandbuf));
if (env_get(process_get_pgid(), "help", (void*)commandbuf, sizeof(commandbuf)) == ST_OK) {
mprintf("devices -C command\n");
mprintf("commands: list_all\n");
if (cmdline_parse(get_cmdline(), cmdline_opts) < 0) {
mprintf("Failed to parse commandline arguments\n");
return;
}
if (env_get(process_get_pgid(), "C", (void*)commandbuf, sizeof(commandbuf)) != ST_OK) {
mprintf("ERROR C=???. No command provided\n");
return;
}
if (strcmp(commandbuf, "list_all") == 0) {
if (cmdline_list_all) {
list_all_devices();
}
}