bash-completion: cleanup and start introducing local uenv labels completion#130
Conversation
f735fa6 to
6fdc2cb
Compare
6fdc2cb to
2fb2445
Compare
|
I still believe that the best way forward is to keep this PR focused, as stated in PR first message
So, trying to recap, IMHO the missing points/tasks for the targeted feature are:
I listed them from higher to lower priority, and I'd say that for this PR:
I'll write here some of the ideas, just to contextualize a bit more. I might eventually move this message/thread to a dedicated issue, depending on the evolution of this PR. 1. SEMANTICThe basic idea is that a uenv label is accepted if the option added in cli has a specific name. Currently there is no homogeneity in naming, so this is the list of commands where a uenv might be specified
I see the next categories
In this PR we aim at just the first category, in particular repo(1) (which can erroneously be suggested more times, see point 2). Moreover, for repo category in general, mount point completion is not taken into account. The point here is that I'm proposing to reflect the option category in the parameter name (names are just indicative, they are just a starting point to give an idea):
2. JUST ONE TIMEI should find a way to detect when a uenv label has been already specified/completed on the command line, so that the completion stop suggesting it. At the moment the only two things I was able to think of are:
The latter sounds like an over-complication to me (and not exactly straightforward considering all the variants). But also the first one is not so easy at the moment. Indeed, we can filter subcommands and flags, but how to filter values for flags? For instance with Any idea? We can eventually decide that this is not so nice but we can live with that while we think for a solution. 3. MULTIPLE UENVsSome commands, specifically 4. LISTINGWhat list should the command use for suggestions?
This might have an answer at an higher level. |
fix problem when a user completes manually a word without adding a space at the end. in this way the logic started working on next completion, but still using the current word (because of the missing space it is considered not complete yet)
bcumming
left a comment
There was a problem hiding this comment.
This looks good.
It is a big improvement over the current status quo. A more complete solution would require a non-trivial restructuring of the completion tooling - specifically we would have to add a callback to the uenv CLI that can generate completions.
So let's go with this solution while we work on the ultimate solution.
DISCLAIMER: I'm not very proficient with bash, and it's my first time dealing with CLI11 and bash completion. Any suggestion is welcome! I opted for opening this PR as draft to start sharing a working (and hopefully evolving) experiment and get some early feedback on this.
I started this as an experiment (over #128 which immediately proved to be useful) to explore how bash completion can be extended for
uenv, in particular targeting auto-completion for uenv images available locally (i.e. start and run).Completion is a broad and complicated feature, and I'd like to keep this PR focused on "uenv labels completion for locally available images" as much as possible, while dealing with other extensions separately. However, current design is quite basic and some auxiliary reworkings might be needed to make this work.
TODO
image ls {uenv}is different fromstart {uenv}image ls %ARCH?