From: Andrii Nakryiko <andriin@fb.com>
To: <andrii.nakryiko@gmail.com>, <netdev@vger.kernel.org>,
<bpf@vger.kernel.org>
Subject: [PATCH v4 bpf-next 3/4] bpftool: add bash completions for btf command
Date: Thu, 25 Apr 2019 15:30:10 -0700 [thread overview]
Message-ID: <20190425223011.284686-4-andriin@fb.com> (raw)
In-Reply-To: <20190425223011.284686-1-andriin@fb.com>
Add full support for btf command in bash-completion script.
Cc: Quentin Monnet <quentin.monnet@netronome.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
tools/bpf/bpftool/bash-completion/bpftool | 46 +++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 9f3ffe1e26ab..bca91d04ed35 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -217,6 +217,7 @@ _bpftool()
done
cur=${words[cword]}
prev=${words[cword - 1]}
+ pprev=${words[cword - 2]}
local object=${words[1]} command=${words[2]}
@@ -607,6 +608,51 @@ _bpftool()
;;
esac
;;
+ btf)
+ local PROG_TYPE='id pinned tag'
+ local MAP_TYPE='id pinned'
+ case $command in
+ dump)
+ case $prev in
+ $command)
+ COMPREPLY+=( $( compgen -W "id map prog file" -- \
+ "$cur" ) )
+ return 0
+ ;;
+ prog)
+ COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) )
+ return 0
+ ;;
+ map)
+ COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) )
+ return 0
+ ;;
+ id)
+ case $pprev in
+ prog)
+ _bpftool_get_prog_ids
+ ;;
+ map)
+ _bpftool_get_map_ids
+ ;;
+ esac
+ return 0
+ ;;
+ *)
+ if [[ $cword == 6 ]] && [[ ${words[3]} == "map" ]]; then
+ COMPREPLY+=( $( compgen -W 'key value kv all' -- \
+ "$cur" ) )
+ fi
+ return 0
+ ;;
+ esac
+ ;;
+ *)
+ [[ $prev == $object ]] && \
+ COMPREPLY=( $( compgen -W 'dump help' -- "$cur" ) )
+ ;;
+ esac
+ ;;
cgroup)
case $command in
show|list)
--
2.17.1
next prev parent reply other threads:[~2019-04-25 22:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 22:30 [PATCH v4 bpf-next 0/4] add btf dumping to bpftool Andrii Nakryiko
2019-04-25 22:30 ` [PATCH v4 bpf-next 1/4] bpftool: add ability to dump BTF types Andrii Nakryiko
2019-04-25 22:30 ` [PATCH v4 bpf-next 2/4] bpftool/docs: add btf sub-command documentation Andrii Nakryiko
2019-04-25 22:30 ` Andrii Nakryiko [this message]
2019-04-25 22:30 ` [PATCH v4 bpf-next 4/4] bpftool: fix indendation in bash-completion/bpftool Andrii Nakryiko
2019-04-26 4:48 ` [PATCH v4 bpf-next 0/4] add btf dumping to bpftool Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190425223011.284686-4-andriin@fb.com \
--to=andriin@fb.com \
--cc=andrii.nakryiko@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox