Skip to content

Commit

Permalink
quote path
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed May 11, 2022
1 parent 6fd587e commit 613a574
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/carapace-spec/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ import (
)

var rootCmd = &cobra.Command{
Use: "carapace-spec",
Short: "",
Use: "carapace-spec",
Long: "define simple completions using a spec file",
Example: ` Spec completion:
bash: source <(carapace-spec example.yaml)
elvish: eval (carapace-spec example.yaml|slurp)
fish: carapace-spec example.yaml | source
oil: source <(carapace-spec example.yaml)
nushell: carapace-spec example.yaml | save example.nu ; nu -c 'source example.nu'
powershell: carapace-spec example.yaml | Out-String | Invoke-Expression
tcsh: eval ` + "`" + `carapace-spec example.yaml` + "`" + `
xonsh: exec($(carapace-spec example.yaml))
zsh: source <(carapace-spec example.yaml)
`,
Args: cobra.MinimumNArgs(1),
DisableFlagParsing: true,
CompletionOptions: cobra.CompletionOptions{
Expand Down Expand Up @@ -110,7 +121,7 @@ func bridgeCompletion(cmd *cobra.Command, spec string, args ...string) {
}

executableName := filepath.Base(executable)
patched := strings.Replace(string(out), fmt.Sprintf("%v _carapace", executableName), fmt.Sprintf("%v %v", executableName, spec), -1) // general callback
patched := strings.Replace(string(out), fmt.Sprintf("%v _carapace", executableName), fmt.Sprintf("%v '%v'", executableName, spec), -1) // general callback
patched = strings.Replace(patched, fmt.Sprintf("'%v', '_carapace'", executableName), fmt.Sprintf("'%v', '%v'", executableName, spec), -1) // xonsh callback
fmt.Print(patched)
}

0 comments on commit 613a574

Please sign in to comment.