diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-22 13:56:47 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-03-22 13:56:47 +0900 |
commit | 34e29a1102d06769987682be5be5d2bd6f1a53bf (patch) | |
tree | 9bae0849f21aa4e0123bd7b33eab60077dacc549 /cli | |
parent | 623de6fbda2ce263c4915dcf992db11045cf33e3 (diff) |
add bash completion for gobgpcli
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'cli')
-rwxr-xr-x | cli/gobgpcli | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli index b2130f2d..f3cde90a 100755 --- a/cli/gobgpcli +++ b/cli/gobgpcli @@ -183,11 +183,17 @@ class Show(object): print neighbors return 0 sorted_neighbors = [] + for n in sorted(neighbors, key=lambda n: n["conf"]["remote_ip"]): + sorted_neighbors.append(n) + if self.options.quiet: + sorted_neighbors_ip = [] + for n in sorted_neighbors: + print str(n["conf"]["remote_ip"]) + return 0 maxaddrlen = 0 maxaslen = 0 maxtimelen = len("Up/Down") - for n in sorted(neighbors, key=lambda n: n["conf"]["remote_ip"]): - sorted_neighbors.append(n) + for n in sorted_neighbors: if len(n["conf"]["remote_ip"]) > maxaddrlen: maxaddrlen = len(n["conf"]["remote_ip"]) if len(str(n["conf"]["remote_as"])) > maxaslen: @@ -370,6 +376,8 @@ def main(): help="specifying a port (8080 by default)") parser.add_option("-d", "--debug", dest="debug", action="store_true", help="dump raw json") + parser.add_option("-q", "--quiet", dest="quiet", action="store_true", + help="for shell completion") (options, args) = parser.parse_args() |