[7/7] autocompletion: add description support

Submitted by Jonatan Schlag on June 19, 2017, 7:20 p.m.

Details

Message ID 1497900050-27692-7-git-send-email-jonatan.schlag@ipfire.org
State Accepted
Commit 9d3ac4e43e607f5278d1b260227f2eb1c58f4f55
Headers show

Commit Message

Jonatan Schlag June 19, 2017, 7:20 p.m.
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/bash-completion/network | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/bash-completion/network b/src/bash-completion/network
index 091c1cb..f7c58a9 100644
--- a/src/bash-completion/network
+++ b/src/bash-completion/network
@@ -59,6 +59,16 @@  _network_color() {
 	fi
 }
 
+_network_description() {
+	local words=( $@ )
+
+	local commands="edit show"
+	local cmd="$(_network_find_on_cmdline "${commands}")"
+	if [[ -z "${cmd}" ]]; then
+		COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+		return 0
+	fi
+}
 _network_device() {
 	local words=( $@ )
 
@@ -258,7 +268,7 @@  _network_port() {
 _network_port_subcommand() {
 	local words=( $@ )
 
-	local commands="color create down edit identify remove status up"
+	local commands="color create description down edit identify remove status up"
 	local cmd="$(_network_find_on_cmdline "${commands}")"
 	if [[ -z "${cmd}" ]]; then
 		COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
@@ -270,6 +280,9 @@  _network_port_subcommand() {
 		color)
 			_network_color ${args}
 			;;
+		description)
+			_network_description ${args}
+			;;
 	esac
 
 }
@@ -378,7 +391,7 @@  _network_zone_subcommand() {
 
 	local words=( $@ )
 
-	local commands="color config disable down edit enable identify port rename status up"
+	local commands="color config description 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}") )
@@ -396,6 +409,9 @@  _network_zone_subcommand() {
 		color)
 			_network_color ${args}
 			;;
+		description)
+			_network_description ${args}
+			;;
 	esac
 }