-
Notifications
You must be signed in to change notification settings - Fork 4
Supply custom argparse types for better completion #15
Copy link
Copy link
Open
Labels
EnhancementNew feature or requestNew feature or requestHelp WantedExtra attention is neededExtra attention is neededPythonRelated to the python code generating completionsRelated to the python code generating completions
Milestone
Description
Currently argparse has a standard mechanism to specify what type to complete (the type argument to add_argument), but doesn't have a mechanism to specify what it is intended to complete with the exception of FileType.
pyzshcomplete should supply custom types that will allow it to make better choice of what is to be completed.
Suggestion:
class ArgparsePidCompleter:
COMPLETE_WITH = 'pids'
def __call__(self, string):
return int(string)which can be used like this:
parser.add_argument('pid', type=ArgparsePidCompleter())Then we can change the complete_with function to do something like this:
@property
def complete_with(self):
...
try:
return self._argument.type.COMPLETE_WITH
except:
pass
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
EnhancementNew feature or requestNew feature or requestHelp WantedExtra attention is neededExtra attention is neededPythonRelated to the python code generating completionsRelated to the python code generating completions