Skip to content

Completion state#774

Merged
tleonhardt merged 30 commits intomasterfrom
completion_state
Sep 16, 2019
Merged

Completion state#774
tleonhardt merged 30 commits intomasterfrom
completion_state

Conversation

@kmvanbrunt
Copy link
Copy Markdown
Member

@kmvanbrunt kmvanbrunt commented Sep 13, 2019

Choices/Completer functions can now be passed a dictionary that maps command-line tokens to their argparse argument. This is helpful when one argument determines what is tab completed for another argument. If these functions have an argument called arg_tokens, then AutoCompleter will automatically pass this dictionary to them.

Closes #762

kmvanbrunt and others added 21 commits August 12, 2019 16:00
… can only have one level of subcommands

No longer creating AutoCompleters for all subcommands each time tab is pressed
…ctions to receive a namespace of all

arguments parsed up to token being completed. This will make it easier to have a previous argument's value
affect what data is tab-completed.
…ompleter/choice

functions that receive parsed_args will still know a flag was used.
Including the token being completed in arg_tokens
@kmvanbrunt kmvanbrunt requested a review from anselor September 13, 2019 21:40
@kmvanbrunt kmvanbrunt self-assigned this Sep 13, 2019
@kmvanbrunt kmvanbrunt added this to the 0.9.17 milestone Sep 13, 2019
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 13, 2019

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.33%. Comparing base (f10674e) to head (c7bf16f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #774      +/-   ##
==========================================
+ Coverage   97.31%   97.33%   +0.02%     
==========================================
  Files          13       13              
  Lines        3459     3455       -4     
==========================================
- Hits         3366     3363       -3     
+ Misses         93       92       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tleonhardt
tleonhardt previously approved these changes Sep 15, 2019
Copy link
Copy Markdown
Member

@tleonhardt tleonhardt left a comment

Choose a reason for hiding this comment

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

Looks good

Comment thread tests/test_argparse_completer.py Outdated
Including tokens from parent parsers in arg_tokens when subcommands are used
Comment thread CHANGELOG.md
* Enhancements
* No longer treating empty text scripts as an error condition
* Allow dynamically extending a `cmd2.Cmd` object instance with a `do_xxx` method at runtime
* Choices/Completer functions can now be passed a dictionary that maps command-line tokens to their
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the change to a dictionary instead of an argparse.Namespace

@tleonhardt tleonhardt merged commit 60ab11c into master Sep 16, 2019
@tleonhardt tleonhardt deleted the completion_state branch September 16, 2019 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pass the namespace to completion function

2 participants