Commit 75bfce75 authored by Michal Berger's avatar Michal Berger Committed by Ben Walker
Browse files

scripts/bash-completion: Extract all rpc methods



Currently we extract these methods from rpc.py's --help or from
rpc_get_methods() in case there's a SPDK application running
in the background. This, however, results in a list missing some
basic methods that rpc_get_methods() simply doesn't include, e.g.
save_subsystem_config().

To make sure we always have a complete list use both, --help and
the rpc_get_methods() together.

Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Change-Id: Ie73917b74860cac13056bea9babc7f7b57e39b3a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14115


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent ae3ae309
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -45,13 +45,11 @@ _get_default_rpc_methods() {
	done < <(_get_help "$1" 2> /dev/null)
}

_get_supported_methods() {
_get_rpc_methods() {
	local method methods

	if ! methods=($("$1" -s "$rpc_sock" rpc_get_methods 2> /dev/null)); then
	_get_default_rpc_methods "$1"
		return 0
	fi
	methods=($("$1" -s "$rpc_sock" rpc_get_methods 2> /dev/null)) || return 0
	((${#methods[@]} > 0)) || return 0

	# Kill the json flavor
@@ -207,11 +205,7 @@ _rpc() {
	local -A rpc_methods=()

	_set_rpc_sock
	if [[ -S $rpc_sock ]]; then
		_get_supported_methods "$rpc"
	else
		_get_default_rpc_methods "$rpc"
	fi
	_get_rpc_methods "$rpc"

	if method=$(_method_in_words); then
		COMPREPLY=($(compgen -W '$(_get_help_rpc_method "$rpc" "$method")' -- "$cur"))