Skip to content

Commit

Permalink
Fixes #35 Removed superfluous offset parameter from completion methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFriendlyCoder committed May 2, 2018
1 parent f2e28b8 commit 4d250e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions sample.py
Expand Up @@ -9,11 +9,10 @@ def do_sub_op(self):

class MyShell (BasicShell):

def complete_parent_op(self, parser, index, len):
def complete_parent_op(self, params, index):
# print("In completer...")
self.debug(str(parser))
self.debug(str(params))
self.debug(str(index))
self.debug(str(len))
options = [
"Hello",
"Howdy",
Expand All @@ -24,7 +23,7 @@ def complete_parent_op(self, parser, index, len):
"JohnDoe",
]

return [i for i in options if i.startswith(parser[index])]
return [i for i in options if i.startswith(params[index])]

def do_parent_op(self):
print("Parent op1")
Expand Down
6 changes: 3 additions & 3 deletions src/friendlyshell/command_complete_mixin.py
Expand Up @@ -193,11 +193,11 @@ def _get_callback_param_index(self, parser, original_line, token):
parser.params[param_index])
return param_index

def _get_completions(self, tmp_method, parser, param_index, token):
def _get_completions(self, tmp_method, parser, param_index):
"""Gets a list of possible matches for a given command parameter"""
self.debug(
'\tCalling into auto completion method %s...', tmp_method.__name__)
retval = tmp_method(parser.params, param_index, len(token))
retval = tmp_method(parser.params, param_index)
self.debug('Found matches: %s', retval)

# Sanity Check: command completion methods MUST always return a list of
Expand Down Expand Up @@ -260,7 +260,7 @@ def _get_completion_matches(self, token):

# Call our auto-completion helper method to get a list of possible
# matches to the partially entered parameter
return self._get_completions(tmp_method, parser, param_index, token)
return self._get_completions(tmp_method, parser, param_index)

def _complete_callback(self, token, index):
"""Autocomplete method called by readline library to retrieve candidates
Expand Down
4 changes: 2 additions & 2 deletions src/friendlyshell/shell_help_mixin.py
Expand Up @@ -122,10 +122,10 @@ def do_help(self, arg=None):
# anywhere in the class hierarchy
self.info('No online help for command "%s"', arg)

def complete_help(self, parser, parameter_index, cursor_position):
def complete_help(self, parser, parameter_index):
"""Automatic completion method for the 'help' command"""
return self._complete_command_names(
parser[parameter_index][:cursor_position])
parser[parameter_index])

def help_help(self):
"""Generates inline help for the 'help' command"""
Expand Down

0 comments on commit 4d250e3

Please sign in to comment.