[6/6] autocompletion: add color commands
Message ID | 1497003452-10190-6-git-send-email-jonatan.schlag@ipfire.org |
---|---|
State | Superseded |
Headers |
Return-Path: <network-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 8198061C91 for <patchwork@ipfire.org>; Fri, 9 Jun 2017 12:18:04 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 3864B280F; Fri, 9 Jun 2017 12:18:04 +0200 (CEST) Received: from ipfire.localdomain (dslb-088-073-203-240.088.073.pools.vodafone-ip.de [88.73.203.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 2761327FA; Fri, 9 Jun 2017 12:17:53 +0200 (CEST) From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: development@lists.ipfire.org, network@lists.ipfire.org Subject: [PATCH 6/6] autocompletion: add color commands Date: Fri, 9 Jun 2017 12:17:32 +0200 Message-Id: <1497003452-10190-6-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1497003452-10190-1-git-send-email-jonatan.schlag@ipfire.org> References: <1497003452-10190-1-git-send-email-jonatan.schlag@ipfire.org> X-BeenThere: network@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List for the network package <network.lists.ipfire.org> List-Unsubscribe: <http://lists.ipfire.org/mailman/options/network>, <mailto:network-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/network/> List-Post: <mailto:network@lists.ipfire.org> List-Help: <mailto:network-request@lists.ipfire.org?subject=help> List-Subscribe: <http://lists.ipfire.org/mailman/listinfo/network>, <mailto:network-request@lists.ipfire.org?subject=subscribe> Errors-To: network-bounces@lists.ipfire.org Sender: "network" <network-bounces@lists.ipfire.org> |
Message
Jonatan Schlag
June 9, 2017, 8:17 p.m. UTC
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
src/bash-completion/network | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
Comments
Hi, On Fri, 2017-06-09 at 12:17 +0200, Jonatan Schlag wrote: > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > --- > 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