]> git.ipfire.org Git - people/ms/network.git/commitdiff
autocompletion: add color commands
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Thu, 15 Jun 2017 16:18:53 +0000 (18:18 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Jun 2017 16:06:22 +0000 (18:06 +0200)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/bash-completion/network

index 4b5e34d30bea82125c946ab9c7592e3138cca071..091c1cb4a824de6bdb15706e09c43f4d129867f9 100644 (file)
@@ -48,6 +48,17 @@ _network_complete_zones() {
        COMPREPLY=( $(compgen -W "$(network raw list-zones)" -- "${cur}") )
 }
 
+_network_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="color create down edit identify remove status up"
        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)
+                       _network_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="color config disable down edit enable identify port rename status up"
        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)
+                       _network_color ${args}
+                       ;;
        esac
 }