Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI bugs regarding command auto-completion #815

Merged
merged 4 commits into from
Jul 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bessctl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ def find_cmd(self, line):
return matched[0]

elif len(matched) >= 2:
for m in matched: # return if exact match exists
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial, nitty: there's a double space here (for m in<space><space>matched).

Q (also pretty trivial): should we capture line.strip() once instead of calling it once per match?

More seriously: it seems like a bad design in general to have complete commands that are prefixes of longer commands. But maybe we have to allow it in general anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chris3torek It was tab 😈...

About the line.strip(), the space at the end here plays a important role, deciding whether it is the end of a token or partial of a token. The design-wise not super clean. ;ㅁ;

if line.strip() == m[0]:
return m

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