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
BF: cmdline: Restore argcomplete functionality #4477
Conversation
The optimization in fb38c70 (OPT/RF: create only the subparser needed for the command, offer "closest" choices, 2018-05-17) sped up datalad, but it (would have [*]) broken the argcomplete-based command-line completion due to the spots in setup_parser() that raise an exception rather than returning the parser that argcomplete needs to inspect. To make completion work again, add a flag to setup_parser() that signals that datalad is being called by argcomplete. In this scenario, avoid failing early so that argcomplete can do its thing. Closes datalad#4473. [*]: When I tried from fb38c70^, completion still didn't work because an exception is raised in config.py due to cfg_kv_regex not matching when datalad is run under argcomplete (for reasons I haven't looked into). But, when I worked around that error, _then_ fb38c70 broke completion. Note that the cfg_kv_regex matching has since changed (b733b04, 2020-04-17) in a way that avoids the config.py exception.
Codecov Report
@@ Coverage Diff @@
## maint #4477 +/- ##
==========================================
- Coverage 89.68% 89.68% -0.01%
==========================================
Files 275 275
Lines 37102 37103 +1
==========================================
Hits 33275 33275
- Misses 3827 3828 +1
Continue to review full report at Codecov.
|
Awesome, thank you @kyleam! I wondered if it would be feasible to craft a test (not necessarily in this PR, but while the track is warm) to sure that argcomplete is happy with us? |
Sure, I'll make an issue and assign it to you so you don't forget ;) |
Ha ha, my track is cold! But I guess I could try by setting that env variable and setting what is spit out |
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.
This works for me! Awesome! Thx!
I hope you'll sort out who will provide the test first. Meanwhile I will merge this and autocomplete all day. Thx much! |
Resolved conflict with master, merged, and pushed. |
The optimization in fb38c70 (OPT/RF: create only the subparser
needed for the command, offer "closest" choices, 2018-05-17) sped up
datalad, but it (would have [*]) broken the argcomplete-based
command-line completion due to the spots in setup_parser() that raise
an exception rather than returning the parser that argcomplete needs
to inspect.
To make completion work again, add a flag to setup_parser() that
signals that datalad is being called by argcomplete. In this
scenario, avoid failing early so that argcomplete can do its thing.
Closes #4473.
[*]: When I tried from fb38c70^, completion still didn't work
because an exception is raised in config.py due to cfg_kv_regex
not matching when datalad is run under argcomplete (for reasons I
haven't looked into). But, when I worked around that error,
then fb38c70 broke completion. Note that the cfg_kv_regex
matching has since changed (b733b04, 2020-04-17) in a way that
avoids the config.py exception.