[asterisk-dev] RFC: internal CLI changes

Luigi Rizzo rizzo at icir.org
Mon Nov 13 07:35:15 MST 2006


I'd be interested in your opinion on the following proposal

	http://bugs.digium.com/view.php?id=8352

Summary: (patch in Mantis)

The current internal API used for CLI commands has the implementation
of a command scattered in far too many places: the command string
is in the ast_cli entry, the usage string is somewhere else, the
handler and the complete- functions are also separate. Finally,
there is no reference to the ast_cli entry passed to the handler,
which is a shame because a lot of useful information could be grabbed
from there (e.g. we would have no more things like argv[5] in the
handler, but just argv[e->args +1], so that if we add or remove a
keyword, the code remains unchanged).

The result of the above is that it is extremely difficult to keep
all these entries aligned, as witnessed by the result of the recent
changes to the CLI (such as the recent list/show and normalization
changes).

In the patch attached, i am trying to address the issue by putting
all the implementation of a cli command in a single function, in a
way that is backward compatible so that we can slowly upgrade
commands from the old to the new format. The patch involves two
files (include/asterisk/cli.h and main/cli.c), and there is at the
end an example on how a new-format handler can be implemented.

	cheers
	luigi


More information about the asterisk-dev mailing list