mirror of https://github.com/dapr/cli.git
feat: support fish shell completion (#1121)
* feat: support fish shell completion Signed-off-by: Alex Lai <alexlai97@163.com> * docs: reword Signed-off-by: Alex Lai <alexlai97@163.com> * Update cmd/completion.go Co-authored-by: Shubham Sharma <shubhash@microsoft.com> Signed-off-by: Alex Lai <alexlai97@outlook.com> Signed-off-by: Alex Lai <alexlai97@163.com> * Update cmd/completion.go Co-authored-by: Shubham Sharma <shubhash@microsoft.com> Signed-off-by: Alex Lai <alexlai97@outlook.com> Signed-off-by: Alex Lai <alexlai97@163.com> * docs: fish completion functions to completions folder [reference](https://fishshell.com/docs/current/completions.html#where-to-put-completions) Signed-off-by: Alex Lai <alexlai97@163.com> Signed-off-by: Alex Lai <alexlai97@163.com> Signed-off-by: Alex Lai <alexlai97@outlook.com> Co-authored-by: Shubham Sharma <shubhash@microsoft.com> Co-authored-by: Alex Lai <laixingyu@cnaeit.com>
This commit is contained in:
parent
0008d46019
commit
f51aefb0ba
|
@ -57,6 +57,12 @@ var completionExample = `
|
|||
# Set the dapr completion code for zsh[1] to autoload on startup
|
||||
dapr completion zsh > "${fpath[1]}/_dapr"
|
||||
|
||||
# Installing fish completion on Linux
|
||||
## Load the dapr completion code for fish into the current shell
|
||||
dapr completion fish | source
|
||||
# Set the dapr completion code for fish[1] to autoload on startup
|
||||
dapr completion fish > $HOME/.config/fish/completions/dapr.fish
|
||||
|
||||
# Installing powershell completion on Windows
|
||||
## Create $PROFILE if it not exists
|
||||
if (!(Test-Path -Path $PROFILE )){ New-Item -Type File -Path $PROFILE -Force }
|
||||
|
@ -77,6 +83,7 @@ func newCompletionCmd() *cobra.Command {
|
|||
cmd.AddCommand(
|
||||
newCompletionBashCmd(),
|
||||
newCompletionZshCmd(),
|
||||
newCompletionFishCmd(),
|
||||
newCompletionPowerShellCmd(),
|
||||
)
|
||||
|
||||
|
@ -112,6 +119,19 @@ func newCompletionZshCmd() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func newCompletionFishCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "fish",
|
||||
Short: "Generates fish completion scripts",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
RootCmd.GenFishCompletion(os.Stdout, true)
|
||||
},
|
||||
}
|
||||
cmd.Flags().BoolP("help", "h", false, "Print this help message")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func newCompletionPowerShellCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "powershell",
|
||||
|
|
Loading…
Reference in New Issue