From 8dc996f6d89652d71c6c4fff87f7923bbfbb9a34 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Fri, 11 Dec 2020 20:13:43 +0100 Subject: move command definitions (as well as helpers) to macros --- src/main.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'src/main.c') 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 " \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 -- cgit v1.2.3