summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-24 00:44:33 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-03-24 00:44:33 -0400
commit94000bf063e28bb20c82177c82a31cee5b0c2817 (patch)
treef51c9fb57a2ac51e8b7444cfb67ad587f6d5e8fb /cmd2.py
parentab865b425866556ca0a2117b9d24582e78d46688 (diff)
downloadcmd2-git-94000bf063e28bb20c82177c82a31cee5b0c2817.tar.gz
Reversed logic for readability
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/cmd2.py b/cmd2.py
index 7cd2ef7f..47ca27ea 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1930,15 +1930,7 @@ class Cmd(cmd.Cmd):
return self.completion_matches[state]
# Check if a valid command was entered
- if command not in self.get_all_commands():
- # Check if this command should be run as a shell command
- if self.default_to_shell and command in get_exes_in_path(command):
- compfunc = functools.partial(path_complete)
- else:
- compfunc = self.completedefault
-
- # A valid command was entered
- else:
+ if command in self.get_all_commands():
# Get the completer function for this command
try:
compfunc = getattr(self, 'complete_' + command)
@@ -1954,6 +1946,14 @@ class Cmd(cmd.Cmd):
index_dict=index_dict,
all_else=compfunc)
+ # A valid command was not entered
+ else:
+ # Check if this command should be run as a shell command
+ if self.default_to_shell and command in get_exes_in_path(command):
+ compfunc = functools.partial(path_complete)
+ else:
+ compfunc = self.completedefault
+
# Call the completer function
self.completion_matches = compfunc(text, line, begidx, endidx)