Skip to content

Commit 005f61b

Browse files
committed
Fix: CLI no more CLI crash when calling a not finish arg line (like opsbro gossip zone). fix #92
(cherry picked from commit 56c4bd2)
1 parent a03debb commit 005f61b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

opsbro/cli.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,11 @@ def __get_execution_context(entry):
495495
def one_loop(self, command_args):
496496
logger.debug("ARGS: %s" % command_args)
497497

498+
first_keyword = command_args[0]
499+
498500
entry = self._get_cli_entry_from_args(command_args)
499501
if entry is None:
500-
self.print_list(command_args[0])
502+
self.print_list(first_keyword)
501503
sys.exit(2)
502504

503505
command_args = self.clean_command_args(command_args)
@@ -506,6 +508,11 @@ def one_loop(self, command_args):
506508
command_parser = optparse.OptionParser('', version="%prog " + VERSION)
507509
command_parser.prog = ''
508510

511+
# Maybe it's not a end node, and we are in the middle, like "opsbro gossip zone"
512+
if not isinstance(entry, CLIEntry):
513+
self.print_list(first_keyword)
514+
sys.exit(2)
515+
509516
for a in entry.args:
510517
n = a.get('name', None)
511518
if n is None:

0 commit comments

Comments
 (0)