Open rashil2000 opened 2 years ago
Sure, I don't see why not.
I'd personally want to see both powershell and bash completions. Ideally WT commands could be run inside WSL(2) and the shell completion could help with that as well.
@zadjii-msft if this were scoped to bash and powershell, I'd like to take a stab at it, as I'd like to learn more about creating shell completions. Interested?
@kkostrzewa I would love the help! Incremental progress is always better than no progress in my book. I honestly don't know where to even start with these - I've never authored shell completion specs for a shell. But I'd love to learn βΊοΈ
@zadjii-msft thx. Feel free to assign this one to me. I'd like to deliver not only an implementation that works for today, but support automated testing, resiliency against new cli args, etc. Not sure yet how to do that.
That would certainly be impressive - but I'll also be more than happy if we just start with the specs in the first PR, then follow up with additional validation. Our unit testing story, especially in that part of the codebase, is a little tricky so I wouldn't want you to overindex on that π
One thing that I've found nice in a lot of modern command line utilities is a pattern where the command itself or a helper command implements the Bash complete -C
interface (looks at some environment variables and outputs the completions I think) as this can be consumed by several shells very easily and even the PowerShell completion script block is fairly boilerplate as well.
You can take a look at AWS CLI Command Line Completion for an example of how this is set up on the consumer side.
See if the pattern done by dotnet.exe will work - https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete. Would require wt.exe --complete
(assuming that flag) would write to stdout
Similar pattern for bash? Maybe wt.exe --complete powershell
or wt.exe --complete bash
That might be Hard - wt.exe
is a WINDOWS subsystem exe, not a CONSOLE one, and there's been historically bad experience trying to mix and match those paradigms.
That being said, there's been talk in the past about doing a wtc.exe
or something that's a CONSOLE exe for interacting with the Terminal.
Yeah, I thought that might be a problem. It may be possible to AttachConsole / AllocConsole when the flag is set so stdout is a valid handle. I'll poc this first, of course, as I've never done anything like this for realz.
Description of the new feature/enhancement
Many apps/tools nowadays provide shell completion files (for bash/zsh/powershell). They help in easy discovery of commandline arguments and are overall a QoL enhancement.
Since
wt
supports a plethora of commandline args, it'be pretty nice to have completion files for PowerShell and CMD (through Clink, if possible).Proposed technical implementation details (optional)
All shells have their own way of defining completions. (For powershell it's
Register-ArgumentCompleter
).Almost all CLI utilities provide the files (examples - ripgrep, gh (CLI), hyperfine). Alacritty, too provides completion files for bash, zsh and fish as a part of their release.