Skip to content

Conversation

@kmvanbrunt
Copy link
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

codecov bot commented Sep 13, 2019

Codecov Report

Merging #774 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
cmd2/cmd2.py 96.78% <100%> (+0.03%) ⬆️
cmd2/argparse_completer.py 100% <100%> (ø) ⬆️
cmd2/argparse_custom.py 94.13% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f10674e...c7bf16f. Read the comment docs.

tleonhardt
tleonhardt previously approved these changes Sep 15, 2019
Copy link
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

Including tokens from parent parsers in arg_tokens when subcommands are used
* 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
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

3 participants