dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
1.05k stars 35 forks source link

`registerCommand(s)` string literal completion #70

Closed curtislarson closed 1 year ago

curtislarson commented 1 year ago

Hello and thanks for the super useful project!

I was fiddling around with the typings for the CommandBuilder and registerCommand/registerCommands in order to support auto completion for custom commands that have been added and was wondering if you would be interested in adding this feature in. It does add a bit of complexity to the CommandBuilder types but I think it can be pretty useful in the long run.

Here is a quick demo of how it works:

https://user-images.githubusercontent.com/2141050/210365688-d7bd5805-df80-448d-a85d-829a6121613b.mov

And here is the commit on my fork (still needs type tests and I'm sure I need to add the LiteralUnion in a few more spots): https://github.com/curtislarson/dax/commit/cd24df64e1f7f7b739a0bc7fabbcf2e06ab0b8e2

Let me know your thoughts!

dsherret commented 1 year ago

Hey @curtislarson, I'm not sure about this because command text is rarely ever just the command name. For example, in most cases a user would do stuff like .command("foobar some args go here"). Also, I think displaying a list of commands here might confuse someone about what the purpose of .command(...) is.