diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-03-29 19:01:06 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-04-10 18:19:03 +0200 |
commit | e31f4dbec66d2ca74fb11e3d5e6506e7a33b508e (patch) | |
tree | 04bf40f3d4dbcd0da9cb306524e40f121e2e7275 | |
parent | Merge pull request #1883 from LabNConsulting/working/master/community-documen... (diff) | |
download | frr-e31f4dbec66d2ca74fb11e3d5e6506e7a33b508e.tar.xz frr-e31f4dbec66d2ca74fb11e3d5e6506e7a33b508e.zip |
lib, python: DEFPY_ATTR, DEFPY_HIDDEN
Add support for element attributes in DEFPY macros.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r-- | lib/command.h | 10 | ||||
-rw-r--r-- | lib/defun_lex.l | 2 | ||||
-rw-r--r-- | python/clidef.py | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/lib/command.h b/lib/command.h index 8d88ea190..508b90538 100644 --- a/lib/command.h +++ b/lib/command.h @@ -221,6 +221,13 @@ struct cmd_node { DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ funcdecl_##funcname +#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ + DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \ + funcdecl_##funcname + +#define DEFPY_HIDDEN(funcname, cmdname, cmdstr, helpstr) \ + DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) + #define DEFUN(funcname, cmdname, cmdstr, helpstr) \ DEFUN_CMD_FUNC_DECL(funcname) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ @@ -298,6 +305,9 @@ struct cmd_node { #else /* VTYSH_EXTRACT_PL */ #define DEFPY(funcname, cmdname, cmdstr, helpstr) \ DEFUN(funcname, cmdname, cmdstr, helpstr) + +#define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ + DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) #endif /* VTYSH_EXTRACT_PL */ /* Some macroes */ diff --git a/lib/defun_lex.l b/lib/defun_lex.l index 87775a0e7..9c995db26 100644 --- a/lib/defun_lex.l +++ b/lib/defun_lex.l @@ -132,6 +132,8 @@ SPECIAL [(),] "DEFUN_NOSH" value = strdup(yytext); return DEFUNNY; "DEFUN_HIDDEN" value = strdup(yytext); return DEFUNNY; "DEFPY" value = strdup(yytext); return DEFUNNY; +"DEFPY_ATTR" value = strdup(yytext); return DEFUNNY; +"DEFPY_HIDDEN" value = strdup(yytext); return DEFUNNY; "ALIAS" value = strdup(yytext); return DEFUNNY; "ALIAS_HIDDEN" value = strdup(yytext); return DEFUNNY; "install_element" value = strdup(yytext); return INSTALL; diff --git a/python/clidef.py b/python/clidef.py index fe01a8916..2e5590964 100644 --- a/python/clidef.py +++ b/python/clidef.py @@ -186,7 +186,7 @@ def process_file(fn, ofd, dumpfd, all_defun): filedata = clippy.parse(fn) for entry in filedata['data']: - if entry['type'] == 'DEFPY' or (all_defun and entry['type'].startswith('DEFUN')): + if entry['type'].startswith('DEFPY') or (all_defun and entry['type'].startswith('DEFUN')): cmddef = entry['args'][2] cmddef = ''.join([i[1:-1] for i in cmddef]) |