Add commands

This commit is contained in:
Lyanis SOUIDI 2024-02-19 02:06:12 +01:00
parent 0da7474158
commit 1896e41b8a
2 changed files with 257 additions and 1 deletions

View File

@ -2,9 +2,222 @@
#include "utils.h"
#include <stdbool.h>
#include <pwd.h>
#include <unistd.h>
Command COMMANDS[] = {
{
command_help,
{{"help", NULL}, NULL},
NULL,
{{"command", "TODO: Add description.", false}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_version,
{{"version", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
},
{
command_config,
{{"config", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_add,
{{"container", "add", NULL}, NULL},
{
{
{"-r", "--root", NULL},
{{"size", "TODO: Add description.", true}, NULL},
"TODO: Add description."
},
{
{"-i", "--image", NULL},
{{"image", "TODO: Add description.", true}, NULL},
"TODO: Add description."
},
NULL
},
{{"container", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_remove,
{{"container", "rm", NULL}, {"container", "remove", NULL}, {"container", "del", NULL}, {"container", "delete", NULL}, NULL},
NULL,
{{"container", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_reset,
{{"container", "reset", NULL}, NULL},
NULL,
{{"container", "TODO: Add description.", true}, NULL},
"Resets the container.",
"TODO: Add details."
},
{
command_container_trim,
{{"container", "trim", NULL}, NULL},
NULL,
{{"container", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_info,
{{"container", "info", NULL}, NULL},
NULL,
{{"container", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_list,
{{"container", "ls", NULL}, {"container", "list", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_wipe,
{{"container", "wipe", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_start,
{{"container", "start", NULL}, NULL},
{
{
{"-p", "--no-pci", NULL},
NULL,
"TODO: Add description."
},
{
{"-v", "--vnc", NULL},
{
{"port", "TODO: Add description.", true},
{"password", "TODO: Add description.", true},
NULL
},
"TODO: Add description."
},
{
{"-i", "--iso", NULL},
{
{"iso", "TODO: Add description.", true},
NULL
},
"TODO: Add description."
},
NULL
},
{{"container", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_stop,
{{"container", "stop", NULL}, NULL},
{
{
{"-f", "--force", NULL},
NULL,
"TODO: Add description."
},
{
{"-t", "--timeout", NULL},
{
{"timeout", "TODO: Add description.", true},
NULL
},
"TODO: Add description."
},
NULL
},
{{"container", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_container_ps,
{{"container", "ps", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
},
{
command_image_sync,
{{"image", "sync", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
},
{
command_image_add,
{{"image", "add", NULL}, NULL},
NULL,
{
{"container", "The name of the container to add.", true},
NULL
},
"TODO: Add details.",
"TODO: Add details."
},
{
command_image_import,
{{"image", "import", NULL}, NULL},
NULL,
{
{"file", "TODO: Add description.", true},
NULL
},
"TODO: Add description.",
"TODO: Add details."
},
{
command_image_remove,
{{"image", "rm", NULL}, {"image", "remove", NULL}, NULL},
NULL,
{{"image", "TODO: Add description.", true}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_image_default,
{{"image", "default", NULL}, NULL},
NULL,
{{"image", "TODO: Add description.", false}, NULL},
"TODO: Add description.",
"TODO: Add details."
},
{
command_image_list,
{{"image", "ls", NULL}, {"image", "list", NULL}, NULL},
NULL,
NULL,
"TODO: Add description.",
"TODO: Add details."
}
};
int main(int argc, char** argv) {
// Ensure the sandbox user exists
struct passwd* pw = getpwnam(SANDBOX_USER);
@ -33,4 +246,24 @@ int main(int argc, char** argv) {
}
// TODO: Parse commands from the command line
}
}
int command_help(int argc, char** argv) { return EXIT_SUCCESS; }
int command_version(int argc, char** argv) { return EXIT_SUCCESS; }
int command_config(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_add(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_remove(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_reset(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_trim(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_info(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_list(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_wipe(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_start(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_stop(int argc, char** argv) { return EXIT_SUCCESS; }
int command_container_ps(int argc, char** argv) { return EXIT_SUCCESS; }
int command_image_sync(int argc, char** argv) { return EXIT_SUCCESS; }
int command_image_add(int argc, char** argv) { return EXIT_SUCCESS; }
int command_image_import(int argc, char** argv) { return EXIT_SUCCESS; }
int command_image_remove(int argc, char** argv) { return EXIT_SUCCESS; }
int command_image_default(int argc, char** argv) { return EXIT_SUCCESS; }
int command_image_list(int argc, char** argv) { return EXIT_SUCCESS; }

View File

@ -1,6 +1,29 @@
#pragma once
#include <stdbool.h>
#define SANDBOX_VERSION "0.1.2"
#define SANDBOX_USER "sandbox"
typedef struct {
const char* name;
const char* description;
const bool required;
} Argument;
typedef struct {
const char** aliases;
const Argument* arguments;
const char* description;
} Option;
typedef struct {
int (*handler)(int argc, char* argv[]);
const char*** aliases;
const Option* options;
const Argument* arguments;
const char* description;
const char* details;
} Command;
int main(int argc, char** argv);