Skip to content

Commit

Permalink
Merge pull request #2047 from rsteube/add-pkgsite
Browse files Browse the repository at this point in the history
added pkgsite
  • Loading branch information
rsteube authored Nov 29, 2023
2 parents 4bf085e + 0812acb commit a13a2cf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
50 changes: 50 additions & 0 deletions completers/pkgsite_completer/cmd/root.go
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(","),
)
}
7 changes: 7 additions & 0 deletions completers/pkgsite_completer/main.go
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()
}

0 comments on commit a13a2cf

Please sign in to comment.