From e21b75db15cf10f6572224c84131afe5bea39544 Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 26 Jul 2023 22:53:16 +0200 Subject: [PATCH] added go-tool-dist --- .../go-tool-dist_completer/cmd/banner.go | 20 +++++++++++ .../go-tool-dist_completer/cmd/bootstrap.go | 23 +++++++++++++ .../go-tool-dist_completer/cmd/clean.go | 20 +++++++++++ completers/go-tool-dist_completer/cmd/env.go | 23 +++++++++++++ .../go-tool-dist_completer/cmd/install.go | 23 +++++++++++++ completers/go-tool-dist_completer/cmd/list.go | 21 ++++++++++++ completers/go-tool-dist_completer/cmd/root.go | 20 +++++++++++ completers/go-tool-dist_completer/cmd/test.go | 34 +++++++++++++++++++ .../go-tool-dist_completer/cmd/version.go | 18 ++++++++++ completers/go-tool-dist_completer/main.go | 7 ++++ pkg/actions/tools/golang/test.go | 3 +- 11 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 completers/go-tool-dist_completer/cmd/banner.go create mode 100644 completers/go-tool-dist_completer/cmd/bootstrap.go create mode 100644 completers/go-tool-dist_completer/cmd/clean.go create mode 100644 completers/go-tool-dist_completer/cmd/env.go create mode 100644 completers/go-tool-dist_completer/cmd/install.go create mode 100644 completers/go-tool-dist_completer/cmd/list.go create mode 100644 completers/go-tool-dist_completer/cmd/root.go create mode 100644 completers/go-tool-dist_completer/cmd/test.go create mode 100644 completers/go-tool-dist_completer/cmd/version.go create mode 100644 completers/go-tool-dist_completer/main.go diff --git a/completers/go-tool-dist_completer/cmd/banner.go b/completers/go-tool-dist_completer/cmd/banner.go new file mode 100644 index 0000000000..d5eba6da1f --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/banner.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var bannerCmd = &cobra.Command{ + Use: "banner", + Short: "print installation banner", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(bannerCmd).Standalone() + + bannerCmd.Flags().BoolS("v", "v", false, "verbosity") + + rootCmd.AddCommand(bannerCmd) +} diff --git a/completers/go-tool-dist_completer/cmd/bootstrap.go b/completers/go-tool-dist_completer/cmd/bootstrap.go new file mode 100644 index 0000000000..cadb932f03 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/bootstrap.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var bootstrapCmd = &cobra.Command{ + Use: "bootstrap", + Short: "rebuild everything", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(bootstrapCmd).Standalone() + + bootstrapCmd.Flags().BoolS("a", "a", false, "rebuild all") + bootstrapCmd.Flags().BoolS("d", "d", false, "enable debugging of bootstrap process") + bootstrapCmd.Flags().BoolS("no-banner", "no-banner", false, "do not print banner") + bootstrapCmd.Flags().BoolS("no-clean", "no-clean", false, "print deprecation warning") + bootstrapCmd.Flags().BoolS("v", "v", false, "verbosity") + rootCmd.AddCommand(bootstrapCmd) +} diff --git a/completers/go-tool-dist_completer/cmd/clean.go b/completers/go-tool-dist_completer/cmd/clean.go new file mode 100644 index 0000000000..82215014f6 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/clean.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var cleanCmd = &cobra.Command{ + Use: "clean", + Short: "deletes all built files", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(cleanCmd).Standalone() + + cleanCmd.Flags().BoolS("v", "v", false, "verbosity") + + rootCmd.AddCommand(cleanCmd) +} diff --git a/completers/go-tool-dist_completer/cmd/env.go b/completers/go-tool-dist_completer/cmd/env.go new file mode 100644 index 0000000000..f340dedcc5 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/env.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var envCmd = &cobra.Command{ + Use: "env", + Short: "print environment", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(envCmd).Standalone() + + envCmd.Flags().BoolS("9", "9", false, "emit plan 9 syntax") + envCmd.Flags().BoolS("p", "p", false, "emit updated $PATH") + envCmd.Flags().BoolS("v", "v", false, "verbosity") + envCmd.Flags().BoolS("w", "w", false, "emit windows syntax") + + rootCmd.AddCommand(envCmd) +} diff --git a/completers/go-tool-dist_completer/cmd/install.go b/completers/go-tool-dist_completer/cmd/install.go new file mode 100644 index 0000000000..cda1b543f4 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/install.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var installCmd = &cobra.Command{ + Use: "install", + Short: "install individual directory", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(installCmd).Standalone() + + installCmd.Flags().BoolS("v", "v", false, "verbosity") + rootCmd.AddCommand(installCmd) + + carapace.Gen(installCmd).PositionalCompletion( + carapace.ActionDirectories(), + ) +} diff --git a/completers/go-tool-dist_completer/cmd/list.go b/completers/go-tool-dist_completer/cmd/list.go new file mode 100644 index 0000000000..5561462a16 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/list.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var listCmd = &cobra.Command{ + Use: "list", + Short: "list all supported platforms", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(listCmd).Standalone() + + listCmd.Flags().BoolS("json", "json", false, "produce JSON output") + listCmd.Flags().BoolS("v", "v", false, "verbosity") + + rootCmd.AddCommand(listCmd) +} diff --git a/completers/go-tool-dist_completer/cmd/root.go b/completers/go-tool-dist_completer/cmd/root.go new file mode 100644 index 0000000000..e5218f5c44 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/root.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "go-tool-dist", + Short: "Dist helps bootstrap, build, and test the Go distribution", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func Execute() error { + return rootCmd.Execute() +} +func init() { + carapace.Gen(rootCmd).Standalone() + +} diff --git a/completers/go-tool-dist_completer/cmd/test.go b/completers/go-tool-dist_completer/cmd/test.go new file mode 100644 index 0000000000..c0bc61f74b --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/test.go @@ -0,0 +1,34 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/golang" + "github.com/spf13/cobra" +) + +var testCmd = &cobra.Command{ + Use: "test", + Short: "run Go test(s)", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(testCmd).Standalone() + + testCmd.Flags().BoolS("asan", "asan", false, "run in address sanitizer builder mode") + testCmd.Flags().StringS("banner", "banner", "", "banner prefix") + testCmd.Flags().BoolS("compile-only", "compile-only", false, "compile tests, but don't run them") + testCmd.Flags().BoolS("k", "k", false, "keep going even when error occurred") + testCmd.Flags().BoolS("list", "list", false, "list available tests") + testCmd.Flags().BoolS("msan", "msan", false, "run in memory sanitizer builder mode") + testCmd.Flags().BoolS("no-rebuild", "no-rebuild", false, "overrides -rebuild (historical dreg)") + testCmd.Flags().BoolS("race", "race", false, "run in race builder mode (different set of tests)") + testCmd.Flags().BoolS("rebuild", "rebuild", false, "rebuild everything first") + testCmd.Flags().StringS("run", "run", "", "run only those tests matching the regular expression") + testCmd.Flags().BoolS("v", "v", false, "verbosity") + rootCmd.AddCommand(testCmd) + + carapace.Gen(testCmd).FlagCompletion(carapace.ActionMap{ + "run": golang.ActionTests(golang.TestOpts{}.Default()), + }) +} diff --git a/completers/go-tool-dist_completer/cmd/version.go b/completers/go-tool-dist_completer/cmd/version.go new file mode 100644 index 0000000000..6a9103a019 --- /dev/null +++ b/completers/go-tool-dist_completer/cmd/version.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "print Go version", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(versionCmd).Standalone() + + rootCmd.AddCommand(versionCmd) +} diff --git a/completers/go-tool-dist_completer/main.go b/completers/go-tool-dist_completer/main.go new file mode 100644 index 0000000000..39bae0d0c4 --- /dev/null +++ b/completers/go-tool-dist_completer/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/rsteube/carapace-bin/completers/go-tool-dist_completer/cmd" + +func main() { + cmd.Execute() +} diff --git a/pkg/actions/tools/golang/test.go b/pkg/actions/tools/golang/test.go index 95ffab0253..e6f7024a37 100644 --- a/pkg/actions/tools/golang/test.go +++ b/pkg/actions/tools/golang/test.go @@ -14,10 +14,11 @@ type TestOpts struct { Test bool } -func (o *TestOpts) Default() { +func (o TestOpts) Default() TestOpts { o.Benchmark = true o.Example = true o.Test = true + return o } // ActionTests completes tests