l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
361 stars 29 forks source link

Autocompletion #39

Open l3nz opened 5 years ago

l3nz commented 5 years ago

I like the idea, though I don't know how it should work:

See https://github.com/oclif/plugin-autocomplete

jwhitlark commented 5 years ago

It kinda seems like we could just have a few templates that are filled in. zsh completion doesn't seem that hard to generate. https://mads-hartmann.com/2017/08/06/writing-zsh-completion-scripts.html

I would add it as "completion $SHELL" so, like kubectl, you can just run it with your shell name and it'll insert it into the current environment. (or source it). Perhaps protect it with a setting, so if people want to use completion as one of their commands, it doesn't contradict.

l3nz commented 5 years ago

we could make it something pretty unlikely and default; you do not often use --shell-completion as an argument for your source file name, right?

jwhitlark commented 5 years ago

No, I don't.

That sounds like a plan to me. If I have any time, I'll take a stab at it.

Are you going to the conj, by any chance?

On Sun, 25 Nov 2018, 07:39 lenz <notifications@github.com wrote:

we could make it something pretty unlikely and default; you do not often use --shell-completion as an argument for your source file name, right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/l3nz/cli-matic/issues/39#issuecomment-441449438, or mute the thread https://github.com/notifications/unsubscribe-auth/AADovN8QYPePrHCGWlxMPztjxFRsJPc6ks5uyrmmgaJpZM4YBUUL .

l3nz commented 5 years ago

See also: https://godoc.org/github.com/codegangsta/cli#BashCompleteFunc

l3nz commented 5 years ago

pip3 has it too:

[~]$ pip3 completion --bash

# pip bash completion start
_pip_completion()
{
    COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   PIP_AUTO_COMPLETE=1 $1 ) )
}
complete -o default -F _pip_completion pip3
# pip bash completion end

$ pip3 completion --fish $ pip3 completion --zsh

l3nz commented 4 years ago

See also: https://tuzz.tech/blog/how-bash-completion-works

l3nz commented 4 years ago

See also: https://news.ycombinator.com/item?id=23254432

l3nz commented 3 years ago

This project has a wondeful on-line help: https://github.com/chriswalz/bit that seems to be created with https://github.com/posener/complete/tree/master