Skip to content

Commit

Permalink
go: added help
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Mar 10, 2023
1 parent 751416d commit 55d6c81
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions completers/go_completer/cmd/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var helpCmd = &cobra.Command{
Use: "help",
Short: "Show help on command or topic",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(helpCmd).Standalone()

rootCmd.AddCommand(helpCmd)

carapace.Gen(helpCmd).PositionalCompletion(
carapace.Batch(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
vals := make([]string, 0)
for _, cmd := range rootCmd.Commands() {
if !cmd.Hidden && cmd != helpCmd {
vals = append(vals, cmd.Name(), cmd.Short)
}
}
return carapace.ActionValuesDescribed(vals...)
}).Style(style.Blue).Tag("commands"),
carapace.ActionValuesDescribed(
"buildconstraint", "build constraints",
"buildmode", "build modes",
"c", "calling between Go and C",
"cache", "build and test caching",
"environment", "environment variables",
"filetype", "file types",
"go.mod", "the go.mod file",
"gopath", "GOPATH environment variable",
"gopath-get", "legacy GOPATH go get",
"goproxy", "module proxy protocol",
"importpath", "import path syntax",
"modules", "modules, module versions, and more",
"module-get", "module-aware go get",
"module-auth", "module authentication using go.sum",
"packages", "package lists and patterns",
"private", "configuration for downloading non-public code",
"testflag", "testing flags",
"testfunc", "testing functions",
"vcs", "controlling version control with GOVCS",
).Tag("topics"),
).ToA(),
)
}

0 comments on commit 55d6c81

Please sign in to comment.