Open WhyNotHugo opened 7 years ago
Hey, thanks!
A new contrib
directory would've fine. If you can, installation instructions for these would be nice (though I write those if you've no idea how).
I opened a pull request just now. Let's continue the discussion there.
Recently I've been working on trying to get completion working with fish, and realized that click
has built-in support to generate completions for a variety of shells (see #543 for a little more context):
click
docs on generating completions for a given shellclick
docs on customizing argument and option value completionsRight now you can get (1) out of the box w/ todo
; however, (2) requires implementing a shell_complete
method per argument or option. It's not perfect, but I've got a sample for todo new --list
in this fork:
https://github.com/johnjameswhitman/todoman/blob/4a00d7ecb20028f4d8f3173928e4cd24849e97c4/todoman/cli.py#L350-L370
Unfortunately, it doesn't seem like you can access the AppContext
that cli
sets up, so you have to create it within the shell completion function. This also means you don't have access to the config
argument passed into the main cli command (at least, I can't figure out how to find it after some debugging). It seems like the completions in contrib
also have this limitation, and either parse the default config location (zsh) or run todo w/o specifying a config (bash). So, implementing shell completion within todoman/cli.py
may make it easier to maintain across both bash and zsh, plus enable fish.
Is adding click-based support for value-completions a contribution the project would welcome?
Edit: It looks like the interface for completion changed between click
v7 (uses autocompletion) and v8 (uses shell_complete). I see todoman
currently allows click
v7...if we were to implement support, then perhaps that's tied to a major-version bump on todoman
that pins to click
v8+.
https://github.com/pimutils/todoman/blob/31a96d414e2e685be90bfe3c7f067934252d6278/pyproject.toml#L29
Is adding click-based support for value-completions a contribution the project would welcome?
We currently have hand-crafted completions for zsh
and bash
. click-based completions are welcome as long as they don't introduce any regressions.
click
8.0.0 is not very new. I'm fine with making it the minimum supported version.
Hi @hobarrera,
I do have a basic version of tab completion for bash (can also be used in zsh with the compatibility layer, of course). I can open a pull request, but I need to know where to actually put the file in the project. Should we have a new folder
completion
or something?