Skip to content

Switch to shtab for shell completion #135

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

Merged
merged 10 commits into from
Oct 9, 2021
Merged

Switch to shtab for shell completion #135

merged 10 commits into from
Oct 9, 2021

Conversation

casperdcl
Copy link
Contributor

@casperdcl casperdcl commented Aug 19, 2020

@casperdcl casperdcl changed the title Completion fix shtab Fix parser, completions, automation Aug 19, 2020
Copy link
Member

@sbrl sbrl left a comment

Choose a reason for hiding this comment

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

Looks ok to me, but I'm not a Python expert.

/cc @MasterOdin for checking, I think this one slipped through the net.

@MasterOdin
Copy link
Collaborator

MasterOdin commented Dec 28, 2020

Sorry for not reviewing this sooner. I do not have much of an opinion on argcomplete vs shtab, and I've found that both work well on my oh-my-zsh installation on my macOS.

However, I am not keen on adding a dependency that has a classifier of Development Status :: 3 - Alpha (shtab) over one marked Development Status :: 5 - Production/Stable (argcomplete).

The usage string not being automated is on purpose, and should not be changed. I've opened #149 to make the usage string a bit simpler to maintain and with explanation on why its manually done instead of leaving it to argparse for automation.

@casperdcl
Copy link
Contributor Author

@MasterOdin shtab is actually faster than argcomplete and has no side effects (it doesn't execute the program every time <TAB> is pressed). It also supports all zsh features natively in addition to bash.

I think shtab is now mature enough that it could be classified as stable or at least beta. It's used by https://github.com/iterative/dvc.

Feel free to modify this PR (e.g. merge #149 into #135) if you'd like.

@casperdcl
Copy link
Contributor Author

just tagged shtab as Development Status :: 4 - Beta and merged in #149 :)

@casperdcl
Copy link
Contributor Author

casperdcl commented Dec 28, 2020

not sure why the 3.5 build is failing - shtab's pyproject.toml clearly states setuptools>=42 but for some reason https://github.com/tldr-pages/tldr-python-client/pull/135/checks?check_run_id=1618096569 is complaining about setuptools<30.4.

EDIT: ah I see, the way the tests were run they circumvent the setuptools version check. Just fixed.

@MasterOdin
Copy link
Collaborator

MasterOdin commented Jan 2, 2021

Testing this out, I get the following error:

tldr <TAB>
_arguments:comparguments:325: doubled rest argument definition: *::args:->args

I am on macOS 11, using zsh 5.8 and oh-my-zsh.

Base automatically changed from master to main February 8, 2021 15:46
@casperdcl
Copy link
Contributor Author

@bl-ue just rebased

@bl-ue bl-ue requested a review from MasterOdin May 3, 2021 14:30
@bl-ue
Copy link
Contributor

bl-ue commented May 20, 2021

ping @MasterOdin — did you forget about this?

@MasterOdin
Copy link
Collaborator

Sorry @casperdcl for not following up here. Will run through with a comparison of shtab and argcomplete again soon.

@casperdcl
Copy link
Contributor Author

Sure, also just released a new shtab version (v1.3.10) so both bash & zsh completion should work perfectly now

@casperdcl
Copy link
Contributor Author

casperdcl commented Aug 5, 2021

just rebased & added cmd completion too (ebe5548)

Co-authored-by: Casper da Costa-Luis <[email protected]>
@MasterOdin
Copy link
Collaborator

Hm, looks like having flake errors. I think to resolve them, will need to double escape the sequence \\W? Not sure, will look at this shortly.

@casperdcl
Copy link
Contributor Author

@MasterOdin yes, fixed.

@MasterOdin
Copy link
Collaborator

Sorry it's taken so long to get this merged. I really appreciate your contribution and follow through here to get this merged!

@MasterOdin MasterOdin changed the title Fix parser, completions, automation Switch to shtab for shell completion Oct 9, 2021
@MasterOdin MasterOdin merged commit a82812a into tldr-pages:main Oct 9, 2021
@casperdcl casperdcl deleted the completion-fix-shtab branch October 11, 2021 12:44
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.

tldr: error: argument command: invalid choice
4 participants