Skip to content

Commit

Permalink
Cleanup code per comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shinae-woo committed Jul 19, 2018
1 parent d04f5f9 commit de1da4e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bessctl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,27 +341,28 @@ def get_prompt(self):

def find_cmd(self, line):
matched, matched_low = self.list_matched(line, ['full'])
line_stripped = line.strip()

if len(matched) == 1:
return matched[0]

elif len(matched) >= 2:
for m in matched: # return if exact match exists
if line.strip() == m[0]:
for m in matched: # return if exact match exists
if line_stripped == m[0]:
return m

self.err('Ambiguous command "%s". Candidates:' % line.strip())
self.err('Ambiguous command "%s". Candidates:' % line_stripped)
for cmd, desc, _ in matched + matched_low:
self.ferr.write(' %-50s%s\n' % (cmd, desc))

elif len(matched) == 0:
matched, matched_low = self.list_matched(line, ['partial'])
if len(matched) > 0:
self.err('Incomplete command "%s". Candidates:' % line.strip())
self.err('Incomplete command "%s". Candidates:' % line_stripped)
for cmd, desc, _ in matched + matched_low:
self.ferr.write(' %-50s%s\n' % (cmd, desc))
else:
self.err('Unknown command "%s".' % line.strip())
self.err('Unknown command "%s".' % line_stripped)

raise self.InvalidCommandError()

Expand Down

0 comments on commit de1da4e

Please sign in to comment.