Skip to content

Conversation

@kmvanbrunt
Copy link
Member

@kmvanbrunt kmvanbrunt commented Mar 2, 2018

This adds flag-based and index-based tab-completion helper functions.

This closes #288.

Tab completion for subcommand help was also added.

This closes #274

kmvanbrunt and others added 9 commits March 1, 2018 03:49
Moved path_complete out of the Cmd class
Rewrote shell_complete
- Since path_complete got moved outside of cmd2.Cmd and is now a function instead of a method, need to do partial argument binding with functools.partial() instead of functools.partialmethod()
@kmvanbrunt kmvanbrunt requested a review from tleonhardt March 2, 2018 04:42
@tleonhardt tleonhardt requested a review from kotfu March 2, 2018 04:46
@codecov
Copy link

codecov bot commented Mar 2, 2018

Codecov Report

Merging #291 into master will decrease coverage by 0.11%.
The diff coverage is 94.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
- Coverage   91.57%   91.45%   -0.12%     
==========================================
  Files           1        1              
  Lines        1424     1486      +62     
==========================================
+ Hits         1304     1359      +55     
- Misses        120      127       +7
Impacted Files Coverage Δ
cmd2.py 91.45% <94.51%> (-0.12%) ⬇️

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 9aeb231...0ec3c1d. Read the comment docs.

@tleonhardt
Copy link
Member

tleonhardt commented Mar 2, 2018

@kmvanbrunt Before we merge this, I would like to see the following added:

  • Example added which demonstrates the usage of the following new helper functions:
    • flag_based_complete
    • index_based_complete
  • Multiple unit tests to cover these same two new helper functions
    • See test_completion.py for analogous unit tests

@tleonhardt tleonhardt added this to the 0.8.1 milestone Mar 2, 2018
return app


def test_cmd2_subcommand_completion_single_end(sc_app):
Copy link
Member

Choose a reason for hiding this comment

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

These unit tests for subcommand completion should not be deleted. They should simply be refactored to use index_based_complete() or complete() instead of the old complete_subcommand().

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. Thanks for including good unit tests and an example.

@tleonhardt tleonhardt merged commit 17781f2 into master Mar 2, 2018
@tleonhardt tleonhardt deleted the tab_completion branch March 2, 2018 21:58
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.

Add tab-completion helpers for positional and flag-based completion Fix tab completion for subcommand help

3 participants