package nushellimport (shlex)func sanitizeName( string) string {returnstrings.ReplaceAll(, "-", "__")}// Snippet creates the nushell completion script.func ( *cobra.Command) string {returnSnippetSingle(.Name(), false)}// SnippetMulti creates a multi-completer nushell completion script.func ( []string, string, string) string {returnfmt.Sprintf(`%[4]vlet %[1]v_completer = {|place| # backwards compatible workaround for positional completer input, see nushell #18791 let spans = (if ($place | describe) =~ "record" { $place.command } else { $place }) %[2]v $spans.0 _carapace nushell ...$spans | from json}mut current = (($env | default {} config).config | default {} completions)$current.completions = ($current.completions | default {} external)$current.completions.external = ($current.completions.external | default true enable |# backwards compatible workaround for default, see nushell #15654 | upsert completer { if $in == null { $%[1]v_completer } else { $in } })$env.config = $current`, sanitizeName(), shlex.Quote(uid.Executable(), shlex.Nushell), "", )}// SnippetSingle creates a single-command nushell completion script.// When explicitCommand is true, the command name is included in the invocation// (for multi-completer subcommands) and the full config setup is included.// When false, only the minimal completer function is generated (standalone mode).func ( string, bool) string {if {returnfmt.Sprintf(`let %[2]v_completer = {|place| # backwards compatible workaround for positional completer input, see nushell #18791 let spans = (if ($place | describe) =~ "record" { $place.command } else { $place }) %[1]v %[3]v _carapace nushell ...$spans | from json}mut current = (($env | default {} config).config | default {} completions)$current.completions = ($current.completions | default {} external)$current.completions.external = ($current.completions.external | default true enable |# backwards compatible workaround for default, see nushell #15654 | upsert completer { if $in == null { $%[2]v_completer } else { $in } })$env.config = $current`, shlex.Quote(uid.Executable(), shlex.Nushell), sanitizeName(), shlex.Quote(, shlex.Nushell)) }returnfmt.Sprintf(`let %v_completer = {|place| # backwards compatible workaround for positional completer input, see nushell #18791 let spans = (if ($place | describe) =~ "record" { $place.command } else { $place }) %v _carapace nushell ...$spans | from json}`, sanitizeName(), shlex.Quote(uid.Executable(), shlex.Nushell))}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.