aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-12-11 20:13:43 +0100
committerJan200101 <sentrycraft123@gmail.com>2020-12-11 20:13:43 +0100
commit8dc996f6d89652d71c6c4fff87f7923bbfbb9a34 (patch)
tree66654d7fabd4a792989d7a32147ba688853c76fa /src/main.c
parent3b3d30aedf3d8762558e9aef846ca94dc492fa96 (diff)
downloadpolecat-8dc996f6d89652d71c6c4fff87f7923bbfbb9a34.tar.gz
polecat-8dc996f6d89652d71c6c4fff87f7923bbfbb9a34.zip
move command definitions (as well as helpers) to macros
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/main.c b/src/main.c
index 352694f..13364dc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,20 +18,9 @@ const static struct Command main_commands[] = {
};
-int main(int argc, char** argv)
-{
- if (argc > 1)
- {
- for (int i = 0; i < ARRAY_LEN(main_commands); ++i)
- {
- if (!strcmp(main_commands[i].name, argv[1])) return main_commands[i].func(argc-1, argv+1);
- }
- }
-
- return main_help(argc-1, argv+1);
-}
+COMMAND_GROUP_FUNC(main)
-int main_env(int argc, char** argv)
+COMMAND(main, env)
{
char buffer[PATH_MAX];
@@ -51,11 +40,4 @@ int main_env(int argc, char** argv)
return 0;
}
-int main_help(int argc, char** argv)
-{
- puts(USAGE_STR " <command>\n\nList of commands:");
-
- print_help(main_commands, ARRAY_LEN(main_commands));
-
- return 0;
-} \ No newline at end of file
+COMMAND_HELP(main, "") \ No newline at end of file