Skip to content

Commit

Permalink
allow to use json and text in the show neighbor command
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Oct 17, 2024
1 parent 0cea371 commit ec4f83e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/exabgp/reactor/api/command/neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,17 @@ def teardown(self, reactor, service, line):
return False


@Command.register('text', 'show neighbor', False, ['summary', 'extensive', 'configuration', 'json'])
@Command.register('text', 'show neighbor', False, ['summary', 'extensive', 'configuration'])
@Command.register('text', 'show neighbor text', False, ['summary', 'extensive', 'configuration'])
@Command.register('json', 'show neighbor json', False, ['summary', 'extensive', 'configuration'])
def show_neighbor(self, reactor, service, command):
words = command.split()

extensive = 'extensive' in words
configuration = 'configuration' in words
summary = 'summary' in words
jason = 'json' in words
text = 'text' in words

if summary:
words.remove('summary')
Expand All @@ -216,6 +219,10 @@ def show_neighbor(self, reactor, service, command):
words.remove('configuration')
if jason:
words.remove('json')
if text:
words.remove('text')

use_json = json and not text

limit = words[-1] if words[-1] != 'neighbor' else ''

Expand Down Expand Up @@ -259,7 +266,7 @@ def callback_summary():
yield True
reactor.processes.answer_done(service)

if jason:
if use_json:
reactor.asynchronous.schedule(service, command, callback_json())
return True

Expand Down

0 comments on commit ec4f83e

Please sign in to comment.