-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2047 from rsteube/add-pkgsite
added pkgsite
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/net" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "pkgsite", | ||
Short: "Pkgsite extracts and generates documentation for Go programs", | ||
Long: "https://pkg.go.dev/golang.org/x/pkgsite/cmd/pkgsite", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().BoolS("cache", "cache", false, "fetch from the module cache") | ||
rootCmd.Flags().StringS("cachedir", "cachedir", "", "module cache directory") | ||
rootCmd.Flags().BoolS("dev", "dev", false, "enable developer mode") | ||
rootCmd.Flags().BoolS("gopath_mode", "gopath_mode", false, "assume that local modules' paths are relative to GOPATH/src") | ||
rootCmd.Flags().StringS("gorepo", "gorepo", "", "path to Go repo on local filesystem") | ||
rootCmd.Flags().StringS("http", "http", "", "HTTP service address to listen for incoming requests on") | ||
rootCmd.Flags().BoolS("list", "list", false, "for each path, serve all modules in build list") | ||
rootCmd.Flags().BoolS("open", "open", false, "open a browser window to the server's address") | ||
rootCmd.Flags().BoolS("proxy", "proxy", false, "fetch from GOPROXY if not found locally") | ||
rootCmd.Flags().StringS("static", "static", "", "path to folder containing static files served") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"cachedir": carapace.ActionDirectories(), | ||
"gorepo": carapace.ActionDirectories(), | ||
"http": carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { | ||
switch len(c.Parts) { | ||
case 0: | ||
return carapace.ActionValues() | ||
default: | ||
return net.ActionPorts() | ||
} | ||
}), | ||
"static": carapace.ActionDirectories(), | ||
}) | ||
|
||
carapace.Gen(rootCmd).PositionalCompletion( | ||
carapace.ActionDirectories().List(","), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/rsteube/carapace-bin/completers/pkgsite_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |