From 38ae54675fa5ea5a9bab5870b0a966e5f3da66ca Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Fri, 14 May 2010 17:14:13 -0700 Subject: POC implementation of unified enumeration mechanism * use "enumeration" template field for both CLI completion and GUI2 enumeration support. * CLI completion now uses enumeration if it exists. * add "existing-interfaces" script as an example. --- etc/bash_completion.d/20vyatta-cfg | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'etc') diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index 62a5440..03f0bb2 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -643,6 +643,7 @@ vyatta_parse_tmpl () # $1: tmpl vyatta_cfg_help="" vyatta_cfg_type="" + vyatta_cfg_enum='' vyatta_cfg_tag=0 vyatta_cfg_multi=0 vyatta_cfg_allowed=() @@ -659,11 +660,18 @@ vyatta_parse_tmpl () s/^tag:.*/vyatta_cfg_tag=1/p s/^multi:.*/vyatta_cfg_multi=1/p s/^type:[ ]\+\([^ ;]\+\)\(;.*\)\?/vyatta_cfg_type=\1/p + s/^enumeration:[ ]\+\([^ ]\+\)/vyatta_cfg_enum=\1/p ' $1` vyatta_cfg_help=$(vyatta_parse_tmpl_comp_fields $1 "help") local acmd=$(vyatta_parse_tmpl_comp_fields $1 "allowed") + if [ -n "$vyatta_cfg_enum" ]; then + local enum_script="/opt/vyatta/share/enumeration/$vyatta_cfg_enum" + if [ -f "$enum_script" ] && [ -e "$enum_script" ]; then + acmd="$enum_script" + fi + fi vyatta_cfg_comp_help=$(vyatta_parse_tmpl_comp_fields $1 "comp_help") if (( ${#vyatta_cfg_allowed[@]} == 0 )); then -- cgit v1.2.3