From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: network@lists.ipfire.org Subject: Re: [PATCH 2/2] ipsec: also show only valid options in the autocompletion Date: Thu, 07 Sep 2017 20:45:51 +0100 Message-ID: <1504813551.18494.15.camel@ipfire.org> In-Reply-To: <1503934373-8996-2-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0488368994681119758==" List-Id: --===============0488368994681119758== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, technically this work, but is it not better to have a command that checks what type a connection is (rw or n2n) and then the right list of commands will be selected? I think that is cleaner instead of heaving some auto-completion stuff in the main library. Best, -Michael On Mon, 2017-08-28 at 17:32 +0200, Jonatan Schlag wrote: > 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=( $@ ) > > - local commands="authentication color description down inactivity- > timeout local mode peer remote security-policy show up" > + local commands="$(network raw list-valid-ipsec-options > "${connection}" "first")" > local cmd="$(_network_find_on_cmdline "${commands}")" > if [[ -z "${cmd}" ]]; then > COMPREPLY=( $(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_remot > e ${connection} "local" ${args} > ;; > @@ -529,6 +532,18 @@ > _network_vpn_ipsec_connection_subcommands_security_policy() { > fi > } > > +_network_vpn_ipsec_connection_subcommands_dpd() { > + local connection=${1} > + shift > + local words=( $@ ) > + > + local commands="$(network raw list-valid-ipsec-options > "${connection}" "dpd")" > + local cmd="$(_network_find_on_cmdline "${commands}")" > + if [[ -z "${cmd}" ]]; then > + COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") ) > + return 0 > + fi > +} > _network_vpn_security_policies() { > local words=( $@ ) > > 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 "$@" > ;; --===============0488368994681119758== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUFCQ2dBZEZpRUU1L3JXNWwzR0dl Mnlwa3R4Z0hudy8yK1FDUWNGQWxteG9lOEFDZ2tRZ0hudy8yK1EKQ1FmZDNRLzlIRTJ0Sk9KTW4w TThIUFdndXFaQWRtckxMMnhoOUZEaEFUMlFtNUhjbFhkVUxrL3A3TVllNis0Rgp0d3FEVG50WHV5 OXl3bzIxOCtKZHNIZjZXN0lBNGg5RmVJK282Y2ltVTRsMHVWU0tDQ09YVWlLVzdQWlBqY1lpCmxt Ukx3dGJ3R2pXZG4xU2JrZ0tQdHlrTkkrNkNJQWtPYzlRS2tNMVBScW5yUHAycFV6MGNLZU4zLzMw TjRXNmwKL0hvcnlxNWFlblRFRXJPM2RrRnhaVDVuZTRRVVNGNzJZSE1WVWxWZFZwc3U5clN1aldF cTNFalBWd3QxN0hxSgpjYW9VdlUrdURCVm9va2pkZnZibEVSMWM3a3dpbmlRR3Y1bXpwWkpuVmdG VGpkYncvLzd5UnNKZE92akZFRDdpClRRRTJreXp0Mi9BaUVrS2JYNHlXaTV1L2c5a3E0T0U5N0tV SlU0OWNOMmphN1c2WkFSaDFZYkhrZUp0ajFj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