#include #include #include // This export commands, good place for write is global header file CLI_REGISTER_COMMANDS(commands) // // --------------------------------------------------------------- int cmd_test1(void *cmds, int idx, FILE *out, char ** __restrict args) { cliCommands_t *c = cmds; if (!args || !args[1]) { cli_PrintHelp(out, cmds, idx); return -1; } cli_Printf(out, "I`m in test1 %s!\n", args[1]); return 0; } int cmd_show(void *cmds __attribute__((unused)), int idx, FILE *out, char ** __restrict args) { if (!args) return -1; cli_Printf(out, "I`m in show!\n"); return 0; } // --------------------------------------------------------------- const char *arg2[] = { "1_", "2_[range]", NULL }; CLI_MAKE_COMP_ARGS(comp_2arg, arg2) const char *show[] = { "1_[from_event]", "2_[to_event]", NULL }; CLI_MAKE_COMP_ARGS(comp_show, show) CLI_MAKE_COMP_COMMANDS(comp_help, commands) cliCommands_t commands[] = { { "test1", cmd_test1, "Test1 function", "test1 [range] ", comp_2arg }, { "test0", cli_Cmd_Unsupported, "Test0 function", "test0 ", NULL }, { "show", cmd_show, "Show information", "show [from_event] [to_event] ", comp_show }, { "-------", NULL, "---------------------", NULL, NULL }, { "help", cli_Cmd_Help, "Help screen", "help [command] ", comp_help }, { "exit", cli_Cmd_Exit, "Exit from console", "exit ", NULL }, { NULL, NULL, NULL, NULL, NULL } }; // --------------------------------------- int main() { int ret; ret = cliExec(commands, stdout, "test>"); return 0; }