Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pkgsite #2047

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}