Annotation of libaitcli/example/test.c, revision 1.2.2.1
1.1 misho 1: #include <stdio.h>
2: #include <string.h>
3: #include <aitcli.h>
4:
5:
6: // This export commands, good place for write is global header file
1.2.2.1 ! misho 7: //CLI_REGISTER_COMMANDS(commands)
1.1 misho 8: //
9:
10: // ---------------------------------------------------------------
1.2.2.1 ! misho 11: /*
1.1 misho 12: int cmd_test1(void *cmds, int idx, FILE *out, char ** __restrict args)
13: {
14: cliCommands_t *c = cmds;
15:
16: if (!args || !args[1]) {
17: cli_PrintHelp(out, cmds, idx);
18: return -1;
19: }
20:
21: cli_Printf(out, "I`m in test1 %s!\n", args[1]);
22:
23: return 0;
24: }
25:
26: int cmd_show(void *cmds __attribute__((unused)), int idx, FILE *out, char ** __restrict args)
27: {
28: if (!args)
29: return -1;
30:
31: cli_Printf(out, "I`m in show!\n");
32:
33: return 0;
34: }
35:
36: // ---------------------------------------------------------------
37:
38: const char *arg2[] = { "1_<get|set>", "2_[range]", NULL };
39: CLI_MAKE_COMP_ARGS(comp_2arg, arg2)
40: const char *show[] = { "1_[from_event]", "2_[to_event]", NULL };
41: CLI_MAKE_COMP_ARGS(comp_show, show)
42:
43: CLI_MAKE_COMP_COMMANDS(comp_help, commands)
44:
45: cliCommands_t commands[] = {
46: { "test1", cmd_test1, "Test1 function", "test1 <get|set> [range] <cr>", comp_2arg },
47: { "test0", cli_Cmd_Unsupported, "Test0 function", "test0 <cr>", NULL },
48: { "show", cmd_show, "Show information", "show [from_event] [to_event] <cr>", comp_show },
49: { "-------", NULL, "---------------------", NULL, NULL },
50: { "help", cli_Cmd_Help, "Help screen", "help [command] <cr>", comp_help },
51: { "exit", cli_Cmd_Exit, "Exit from console", "exit <cr>", NULL },
52: { NULL, NULL, NULL, NULL, NULL }
53: };
1.2.2.1 ! misho 54: */
1.1 misho 55:
56: // ---------------------------------------
57:
58: int main()
59: {
60: int ret;
1.2.2.1 ! misho 61: linebuffer_t *t;
1.1 misho 62:
1.2.2.1 ! misho 63: // ret = cliExec(commands, "test>");
! 64: t = cliInit(0, 1, "test>");
! 65: ret = cliLoop(t, NULL);
! 66: cliEnd(t);
1.1 misho 67:
68: return 0;
69: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>