summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-06-18 10:42:19 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-06-23 16:31:07 +0900
commit40beabffc3c8ca721ec57c3d7fe06d2bb9f3d710 (patch)
treef259f5dcb6f03504d51a1d8f005bc74b124ea85f /tools
parentc8b0030e32cb2938b6f94e5f1c50d95279c59207 (diff)
cli: update to auto-complete the IP address of the neighbor
Diffstat (limited to 'tools')
-rw-r--r--tools/completion/gobgp-completion.bash33
1 files changed, 31 insertions, 2 deletions
diff --git a/tools/completion/gobgp-completion.bash b/tools/completion/gobgp-completion.bash
index 68718cf7..1f88a3c5 100644
--- a/tools/completion/gobgp-completion.bash
+++ b/tools/completion/gobgp-completion.bash
@@ -1,5 +1,15 @@
#!/bin/bash
+__gobgp_q() {
+ gobgp 2>/dev/null "$@"
+}
+
+__gobgp_q_neighbor() {
+ neighbors=( $(__gobgp_q $url $port --quiet $q_type) )
+ for n in ${neighbors[*]}; do
+ must_have_one_noun+=($n)
+ done
+}
__debug()
{
@@ -106,7 +116,12 @@ __handle_flag()
commands=()
fi
fi
-
+ if [ ${words[(c-1)]} == "-u" ]; then
+ url="-u ${words[(c)]}"
+ fi
+ if [ ${words[(c-1)]} == "-p" ]; then
+ port="-p ${words[(c)]}"
+ fi
# skip the flag itself
c=$((c+1))
@@ -233,6 +248,16 @@ _gobgp_neighbor()
{
last_command="gobgp_neighbor"
commands=()
+ commands+=("local")
+ commands+=("adj-in")
+ commands+=("adj-out")
+ commands+=("reset")
+ commands+=("softreset")
+ commands+=("softresetin")
+ commands+=("softresetout")
+ commands+=("shutdown")
+ commands+=("enable")
+ commands+=("disable")
flags=()
two_word_flags=()
@@ -246,6 +271,8 @@ _gobgp_neighbor()
must_have_one_flag=()
must_have_one_noun=()
+ q_type="neighbor"
+ __gobgp_q_neighbor
}
_gobgp_policy_prefix_add()
@@ -652,12 +679,14 @@ _gobgp_help()
_gobgp()
{
+ url=""
+ port=""
+ q_type=""
last_command="gobgp"
commands=()
commands+=("global")
commands+=("neighbor")
commands+=("policy")
- commands+=("help")
flags=()
two_word_flags=()