-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
feature: Shell completions #27
Comments
Uups ... you already created one. |
Ah, let me keep this one then, it helps to have the actual author in the issue metadata 🙂 |
I hope that moving on to this issue will not result in losing my small funding. I have never heard of Polar.sh before, but I like any idea that can make Open-Source more sustainable. |
Oh, so sorry, I missed that! |
I setup issue boosting recently, as an experiment and after user feedback, and you're the first one to boost an issue 😄 I may not be the one resolving it, but rest assured it's now in the top of our backlog and will be handled very soon 😄 |
No hurry. I just noticed that you’re a significant contributor to open-source projects, which I truly admire (I contribute to various Open-Source projects myself). I’m particularly interested in the idea of making the open-source community more financially sustainable - it’s such an important topic. |
Oh I didn't know invoke wasn't maintained! Lets make duty even better then 😄 |
What shells should we support? |
Most common ones probably, if they are supported by the lib we'll use: bash, zsh, fish, powershell. |
alrighty! couple of questions from the technical POV, as i am implementing this—@pawamoy:
some other research notes
(i was wondering if we could save some time and not have to actually run the program to register commands only for completions, and instead have these commands somehow statically prepared from the last save; but ig it doesn't matter that much, it would be unreliable, we need to collect that info from runtime anyway) |
Thanks for the analysis @bswck!
I wonder if we really need shell detection. I believe many tools just expect a flag like
I had recent thoughts about this. Usually, projects start out as However here we probably always install duty to be used as a CLI (even in CI), so I don't think it's worth creating separate projects just to avoid the shell-detection library (if we decide to use one) and auto-completion library. |
I'm not sure why we would want that. Our CLI shape doesn't change based on the shell (unless I'm missing something?), so we probably don't need to do that? |
Yeah, running the program in a Python interpreter each time we hit tab makes things slow. That's an issue with Python and dynamic CLIs, and I'm afraid there's not much we can do without over-engineering things. Happy to be proven otherwise, maybe there are completion frameworks that provide clever features to make things fast. |
% pdm completion --help
Usage: pdm completion [-h] [shell]
Generate completion scripts for the given shell
Positional Arguments:
shell The shell to generate the scripts for. If not given, PDM will properly guess from `SHELL` env var.
Options:
-h, --help Show this help message and exit. Seems good enough to me, WDYT? |
makes sense. shellingham also suggests a routine for basic shell detection regarding the |
I was tempted to try out argcomplete... but after diving into the implementation details it has, I'm honestly discouraged. I think we can roll out our own, hardcoded solution |
OK, sounds good to me! By hardcoded solution you mean scripts for each shell we want to support, and maybe a few updates to the Python CLI to return the necessary completion data? |
@medihack what shell are you using? |
I only use |
Thanks! @bswck I'll consider it resolved if we only implement Bash and Zsh completions for now. With the code in place, it will be easy to add Fish and Powershell completions later if we want to (or if users request it). What do you both think? |
@medihack @pawamoy please guide me: which way of finding completions do we consider desired for a simple use case below? for a shell prompt
do we expect: (1) (2) or (3) ? all options make sense. Footnotes
|
I'd expect only |
Is your feature request related to a problem? Please describe.
It would be nice to have shell completions of the available duties and parameters for convenience.
Describe the solution you'd like
Something similar to what invoke has.
Describe alternatives you've considered
None
Additional context
None
Boost priority
The text was updated successfully, but these errors were encountered: