From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: network@lists.ipfire.org Subject: Re: [PATCH 6/6] autocompletion: add color commands Date: Wed, 14 Jun 2017 22:12:09 +0100 Message-ID: <1497474729.2416.17.camel@ipfire.org> In-Reply-To: <1497003452-10190-6-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6308172134280670521==" List-Id: --===============6308172134280670521== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Hi, On Fri, 2017-06-09 at 12:17 +0200, Jonatan Schlag wrote: > Signed-off-by: Jonatan Schlag > --- >  src/bash-completion/network | 30 ++++++++++++++++++++++++++---- >  1 file changed, 26 insertions(+), 4 deletions(-) > > diff --git a/src/bash-completion/network b/src/bash- > completion/network > index 4b5e34d..321d0ff 100644 > --- a/src/bash-completion/network > +++ b/src/bash-completion/network > @@ -48,6 +48,17 @@ _network_complete_zones() { >   COMPREPLY=( $(compgen -W "$(network raw list-zones)" -- > "${cur}") ) >  } >   The function below should be prefixed with _network, because _color is quite a common name and could be used by something else as well. > +_color() { > + local words=( $@ ) > + > + local commands="set reset" > + local cmd="$(_network_find_on_cmdline "${commands}")" > + if [[ -z "${cmd}" ]]; then > + COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") > ) > + return 0 > + fi > +} > + >  _network_device() { >   local words=( $@ ) >   > @@ -78,7 +89,7 @@ _network_device_subcommand() { >   COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") > ) >   return 0 >   fi > - > + >   case "${cmd}" in >   ussd) >   # TODO > @@ -247,12 +258,20 @@ _network_port() { >  _network_port_subcommand() { >   local words=( $@ ) >   > - local commands="create down edit identify remove status up" > + local commands="create down edit identify remove status up > color" Could you order the commands alphabetically? >   local cmd="$(_network_find_on_cmdline "${commands}")" >   if [[ -z "${cmd}" ]]; then >   COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") > ) >   return 0 >   fi > + > + local args="${words[@]:1}" > + case "${cmd}" in > + color) > + _color ${args} > + ;; > + esac > + >  } >   >  _network_route() { > @@ -359,13 +378,13 @@ _network_zone_subcommand() { >   >   local words=( $@ ) >   > - local commands="config disable down edit enable identify > port rename status up" > + local commands="config disable down edit enable identify > port rename status up color" Same as above. >   local cmd="$(_network_find_on_cmdline "${commands}")" >   if [[ -z "${cmd}" ]]; then >   COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") > ) >   return 0 >   fi > - > + >   local args="${words[@]:1}" >   case "${cmd}" in >   config) > @@ -374,6 +393,9 @@ _network_zone_subcommand() { >   port) >   _network_zone_subcommand_port "${zone}" > ${args} >   ;; > + color) > + _color ${args} > + ;; >   esac >  } > -Michael --===============6308172134280670521== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcgdjIKCmlRSWNCQUFC Q2dBR0JRSlpRYWFwQUFvSkVJQjU4UDl2a0FrSFo0WVAvM21TSzQ0TWswZTlQL2p5aDhGcnRmaTEK SWhybEFQYmxjbE5LMVhIZmY0ajV4SG54b1pBTDZocWJMTDVWTEM3VFNNakw4ajdocVN2NFM5Ylli c2sxSkxWZQpLNy91WmtEL3BvN01LdnIxQXBNVXpkckRyUzJhT3I4a1FiSzcvblNGQTRSd3c1c21o TnNQSnppdG9Pc2hUQnI2CmZSWnlFYVIwc1hSSkdrM2h3TW9Ra0VjQmVIdWNvckloZjliVEgxQWZz VnE1dVdIa0Fla2NleVczaU5kb0pnTnYKL0VJa1M2blFKM1J5R3RwWkZKMFRFdGlJWkg4bS9FTFND dkxPS0JsZ21sYU5qSCtwVlNHU0I5VzVhT0RuMC9WZwo1Q2tsUndESDlKT2I4VkI0UnZGNktBQXFH UHkycVRNL04vSE5lRU9aUGtja2NXN2tMQnJ5bW91QXNWUktiemVoCnp6T0o3b05NWkJXdEdXTUp0 NzJSRmZRTVFwOUxV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