-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Commands for generating shell completion scripts + statically-generated bash script #42416
base: main
Are you sure you want to change the base?
Conversation
I've implemented completion script generate for bash based partially on the excellent patterns that the Swift ArgumentParser library has used. Here's an example of the generated script (warning, 2100 lines of bash await you): It works remarkably well - one of the harder parts was figuring out when truly dynamic completions were required and injecting a call to the dotnet CLI's completion command to generate suggestions for those cases. But where completions can be known statically we inject them. There is no good handling for file-based completions yet - one hurdle I faced was the very-pluggable completions model currently doesn't give any sense of attribution of the different completion sources - if I knew a given |
4fa8920
to
6f266e8
Compare
64269f3
to
af2fa73
Compare
af2fa73
to
b93f1b8
Compare
f444ab9
to
a79588a
Compare
src/System.CommandLine.StaticCompletions/shells/ZshShellProvider.cs
Outdated
Show resolved
Hide resolved
Ok, I've updated the description. This is now ready for a review + discussion. I've done almost all of the work in a separate library project - this is something that we should consider spinning off in the future, as the only real dependency it has is System.CommandLine. If that becomes stable then it'd be fitting for a library. Assuming the library is implemented (and there are some baseline tests added) then the usage of the library in the dotnet CLI becomes very simple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look at shell-specific code or test code, but this looks great! I appreciated the videos in the description, but you might need to work on your typing speed (or crop the first half of the video) 😉
src/Cli/dotnet/commands/dotnet-complete/CompleteCommandParser.cs
Outdated
Show resolved
Hide resolved
src/System.CommandLine.StaticCompletions/HelpGenerationExtensions.cs
Outdated
Show resolved
Hide resolved
src/System.CommandLine.StaticCompletions/HelpGenerationExtensions.cs
Outdated
Show resolved
Hide resolved
src/System.CommandLine.StaticCompletions/System.CommandLine.StaticCompletions.csproj
Show resolved
Hide resolved
@baronfel I'm guessing this can only work when the options are statically registered and so it won't work for our new dotnet test experience, right? |
If we have corrected paths from the extension methods, maybe we don't need this override?
By not copying the snapshots to build output, and by making Verify condition the checks for where to look for the snapshots, we can keep a good dev experience of diffs on in-tree files instead of digging in build output directories. CI test failures will still be unfortunately messy.
Co-authored-by: Michael Yanni <MiYanni@microsoft.com>
0401891
to
ebc4095
Compare
Part of #42397
Implements:
Shell Support