From ec4f83e8c5346f5cceaae7938be4b6e5bb9020da Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Thu, 17 Oct 2024 16:57:44 +0100 Subject: [PATCH] allow to use json and text in the show neighbor command --- src/exabgp/reactor/api/command/neighbor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/exabgp/reactor/api/command/neighbor.py b/src/exabgp/reactor/api/command/neighbor.py index c61b645b0..162439d4b 100644 --- a/src/exabgp/reactor/api/command/neighbor.py +++ b/src/exabgp/reactor/api/command/neighbor.py @@ -199,7 +199,9 @@ 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() @@ -207,6 +209,7 @@ def show_neighbor(self, reactor, service, command): configuration = 'configuration' in words summary = 'summary' in words jason = 'json' in words + text = 'text' in words if summary: words.remove('summary') @@ -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 '' @@ -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