-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Determine whether to add a subparser to completion by its presence in _get_subactions()
#47
Conversation
_get_subactions()
_get_subactions()
ae862f6
to
9a41f46
Compare
what about using |
Unfortunately, that results in As a further enhancement here, I notice that shtab uses Another thing I just noticed that I didn't account for is subcommand aliases. I'll write a test for this and fix the patch as needed... |
9a41f46
to
546a840
Compare
… _get_subactions() This is the logic argparse uses for showing a subparser in the list of options, so shtab now matches that behavior. This is particularly important for subparsers which pass `add_help=False` in order to provide their *own* help implementation.
546a840
to
4fac7e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slight tweaks
Codecov Report
@@ Coverage Diff @@
## master #47 +/- ##
==========================================
+ Coverage 88.57% 88.80% +0.22%
==========================================
Files 3 3
Lines 245 250 +5
==========================================
+ Hits 217 222 +5
Misses 28 28
Continue to review full report at Codecov.
|
/tag v1.4.0 1e1d6ef |
Thanks for the quick review/merge! |
Thanks for the contribution! |
This is just a small change to the logic for when to generate completion for a subparser. The new logic is the same that
argparse
uses for showing a subparser in the list of options (i.e. if you don't passhelp
toadd_parser
, that subparser is omitted from your program's overall help message).This is particularly important for subparsers which pass
add_help=False
in order to provide their own help implementation. This is something I do in one of my projects. See here and here for an example.Note: this is a breaking change, since now subparsers with no
help
kwarg will no longer have shell-completion generated for them. I think this is the correct behavior though, and fixing this is easy enough for users of shtab: just sethelp
to something likeNone
or''
(or even better, add an actual help message!).