mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.1k stars 336 forks source link

cmd/shfmt: add shell auto-complete #914

Open Freed-Wu opened 1 year ago

Freed-Wu commented 1 year ago

How about adding shell completions for bash/zsh/fish/posh/etc? Thanks.

❯ shfmt -<TAB>
option
--binary-next-line   binary ops like && and | may start a line
-bn                  binary ops like && and | may start a line
--case-indent        switch cases will be indented
-ci                  switch cases will be indented
...
mvdan commented 1 year ago

Sure, I don't see why not if someone wants to write and maintain that. Ideally there would be a way to do this automatically.

Freed-Wu commented 1 year ago

Ideally there would be a way to do this automatically.

Like https://jmtirado.net/shell-completion-with-cobra-and-go/?

mvdan commented 1 year ago

Yeah, something like that. I want to avoid heavy dependencies like cobra, though. Aside from tests, we are currently light on dependencies, and I want to keep it that way.