|Summary:||ASTERISK-08124: [patch][post-1.4] new internal API for CLI|
|Reporter:||Luigi Rizzo (rizzo)||Labels:|
|Date Opened:||2006-11-13 05:50:45.000-0600||Date Closed:||2006-11-17 16:55:43.000-0600|
|Environment:||Attachments:||( 0) new-cli|
|Description:||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 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.
****** ADDITIONAL INFORMATION ******
Note that while i mark the item as post-1.4, this patch does not add any new feature, and the effort to convert a handler to the new style is the same as the one to fix the command itself, so i would suggest to put this into 1.4.1 as well, and make a gradual shift of the handlers from the old to the new api as we detect breakage in individual cli entries that need to be fixed.
|Comments:||By: Luigi Rizzo (rizzo) 2006-11-17 16:55:42.000-0600|
committed to trunk, with fixes as appropriate.