File:  [ELWIX - Embedded LightWeight unIX -] / libaitcli / example / test.c
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Mar 16 17:24:03 2011 UTC (13 years, 2 months ago) by misho
Branches: MAIN
CVS tags: cli3_3, cli3_2, cli3_1, cli3_0, cli2_3, cli2_2, cli2_1, HEAD, CLI3_2, CLI3_1, CLI3_0, CLI2_3, CLI2_2, CLI2_1, CLI2_0
2.0

#include <stdio.h>
#include <string.h>
#include <aitcli.h>


// 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_<get|set>", "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 <get|set> [range] <cr>", comp_2arg }, 
	{ "test0", cli_Cmd_Unsupported, "Test0 function", "test0 <cr>", NULL }, 
	{ "show", cmd_show, "Show information", "show [from_event] [to_event] <cr>", comp_show }, 
	{ "-------", NULL, "---------------------", NULL, NULL }, 
	{ "help", cli_Cmd_Help, "Help screen", "help [command] <cr>", comp_help }, 
	{ "exit", cli_Cmd_Exit, "Exit from console", "exit <cr>", NULL }, 
	{ NULL, NULL, NULL, NULL, NULL }
};
*/

// ---------------------------------------

int main()
{
	int ret;
	linebuffer_t *t;

//	ret = cliExec(commands, "test>");
	t = cliInit(0, 1, "test>");
	ret = cliLoop(t, NULL);
	cliEnd(t);

	return 0;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>