VTY hacks for automatic document generation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Sun Oct 2 09:06:47 UTC 2011


Hi,

my goal is to generate our wiki pages (or docbook, or...) for the config
formats from the VTY commands directly. We might also want/need to add
additional docs inside the command.


My current hack is this:
diff --git a/src/vty/command.c b/src/vty/command.c
index ab1eaca..bcf72d0 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -426,6 +426,20 @@ void install_element(enum node_type ntype, struct
cmd_element *cmd)

        cmd->strvec = cmd_make_descvec(cmd->string, cmd->doc);
        cmd->cmdsize = cmd_cmdsize(cmd->strvec);
+
+       printf("NODE: %d\n", ntype);
+
+       int j;
+       for (j = 0; j < vector_count(cmd->strvec); ++j) {
+               vector descvec = vector_slot(cmd->strvec, j);
+               int i;
+               for (i = 0; i < vector_active(descvec); i++) {
+                       struct desc *desc = vector_slot(descvec, i);
+                       if (desc == NULL)
+                               continue;
+                       printf(" %s %s\n", desc->cmd, desc->str);
+               }
+       }


Output:
NODE: 1
 show Show running system information
 version Displays program version
NODE: 1
 list Print command list
NODE: 1
 exit Exit current mode and down to previous mode
NODE: 1
 help Description of the interactive help system
NODE: 1
 enable Turn on privileged mode command
NODE: 1
 terminal Set terminal line parameters
 length Set number of lines on a screen
 <0-512> Number of lines on screen (0 for no pausing)
NODE: 1

Problems:
The goal would to have a VTY command to introspect all vty commands, one of
the problems is to do it recursively. E.g. we have commands that move to
another node but this is via code and can not be seen from the outside. The
other problem is we can not get the name from the node number...


PS: Can we move VTY to AGPL code, bit by bit? Remove one public function and
reimplement to make OpenBSC work again? E.g. the vector in vectors is a bit
crazy...






More information about the OpenBSC mailing list