linuxinstall/src/sandbox.c

40 lines
712 B
C
Raw Normal View History

#include "sandbox.h"
#include "utils.h"
2024-02-16 17:13:52 +01:00
#include "command.h"
2024-02-15 19:42:22 +01:00
#include <stdarg.h>
#include <stdio.h>
2024-02-15 19:42:22 +01:00
#include <stdlib.h>
2024-02-16 17:13:52 +01:00
#include <string.h>
int main(int argc, char* argv[]) {
2024-02-16 17:13:52 +01:00
if (argc < 2) {
show_help();
return 0;
}
2024-02-16 16:53:02 +01:00
2024-02-16 17:13:52 +01:00
Command* command = find_command(argv[1]);
if (command == NULL) {
log_message(LOG_ERROR, "Unknown command '%s'.", argv[1]);
return 1;
}
2024-02-16 16:53:02 +01:00
2024-02-16 18:26:02 +01:00
int consumed = 2;
// TODO: Implement log level parameter
2024-02-16 17:13:52 +01:00
switch (command->id) {
case CMD_HELP:
2024-02-16 18:26:02 +01:00
return cmd_help(argc - consumed, argv + consumed);
2024-02-16 17:13:52 +01:00
case CMD_VERSION:
2024-02-16 18:26:02 +01:00
return cmd_version(argc - consumed, argv + consumed);
2024-02-16 17:19:56 +01:00
2024-02-16 17:13:52 +01:00
default:
log_message(LOG_ERROR, "Command '%s' is not implemented.", command->name);
break;
}
2024-02-16 16:53:02 +01:00
2024-02-16 17:13:52 +01:00
return 0;
2024-02-16 16:53:02 +01:00
}