From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonatan Schlag To: network@lists.ipfire.org Subject: [PATCH 2/2] ipsec: also show only valid options in the autocompletion Date: Mon, 28 Aug 2017 17:32:53 +0200 Message-ID: <1503934373-8996-2-git-send-email-jonatan.schlag@ipfire.org> In-Reply-To: <1503934373-8996-1-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4947207914432508344==" List-Id: --===============4947207914432508344== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The options for the different types of connections should be also printed correctly when we use autocompletion Signed-off-by: Jonatan Schlag --- src/bash-completion/network | 17 ++++++++++++++++- src/network | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/bash-completion/network b/src/bash-completion/network index 71bf245..25cf6aa 100644 --- a/src/bash-completion/network +++ b/src/bash-completion/network @@ -413,7 +413,7 @@ _network_vpn_ipsec_connection_subcommands() { shift local words=3D( $@ ) =20 - local commands=3D"authentication color description down inactivity-timeout = local mode peer remote security-policy show up" + local commands=3D"$(network raw list-valid-ipsec-options "${connection}" "f= irst")" local cmd=3D"$(_network_find_on_cmdline "${commands}")" if [[ -z "${cmd}" ]]; then COMPREPLY=3D( $(compgen -W "${commands}" -- "${cur}") ) @@ -432,6 +432,9 @@ _network_vpn_ipsec_connection_subcommands() { description) _network_description ${args} ;; + dpd) + _network_vpn_ipsec_connection_subcommands_dpd "${connection}" ${args} + ;; local) _network_vpn_ipsec_connection_subcommands_local_remote ${connection} "loc= al" ${args} ;; @@ -529,6 +532,18 @@ _network_vpn_ipsec_connection_subcommands_security_polic= y() { fi } =20 +_network_vpn_ipsec_connection_subcommands_dpd() { + local connection=3D${1} + shift + local words=3D( $@ ) + + local commands=3D"$(network raw list-valid-ipsec-options "${connection}" "d= pd")" + local cmd=3D"$(_network_find_on_cmdline "${commands}")" + if [[ -z "${cmd}" ]]; then + COMPREPLY=3D( $(compgen -W "${commands}" -- "${cur}") ) + return 0 + fi +} _network_vpn_security_policies() { local words=3D( $@ ) =20 diff --git a/src/network b/src/network index 9a2d480..379a71d 100644 --- a/src/network +++ b/src/network @@ -1334,6 +1334,9 @@ cli_raw() { list-next-free-zones) zones_get_next_free ;; + list-valid-ipsec-options) + ipsec_get_valid_options "$@" + ;; list-zone-config-ids) zone_config_list_ids "$@" ;; --=20 2.6.3 --===============4947207914432508344==--