cme/cue/cmd: unexport RootCmd
this is to make it compatible with the newer version of Cobra
Change-Id: I79fb64415d946364a0bf5b16ca5e79999c501586
Reviewed-on: https://cue-review.googlesource.com/c/1600
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cmd/cue/cmd/cmd.go b/cmd/cue/cmd/cmd.go
index b1b7f6a..6f72669 100644
--- a/cmd/cue/cmd/cmd.go
+++ b/cmd/cue/cmd/cmd.go
@@ -216,5 +216,5 @@
}
func init() {
- RootCmd.AddCommand(cmdCmd)
+ rootCmd.AddCommand(cmdCmd)
}
diff --git a/cmd/cue/cmd/cmd_test.go b/cmd/cue/cmd/cmd_test.go
index 514a49d..cf51dd3 100644
--- a/cmd/cue/cmd/cmd_test.go
+++ b/cmd/cue/cmd/cmd_test.go
@@ -34,8 +34,8 @@
testOut = cmd.OutOrStdout()
defer func() { testOut = nil }()
- tools := buildTools(RootCmd, args)
- cmd, err := addCustom(RootCmd, "command", name, tools)
+ tools := buildTools(rootCmd, args)
+ cmd, err := addCustom(rootCmd, "command", name, tools)
if err != nil {
return err
}
diff --git a/cmd/cue/cmd/eval.go b/cmd/cue/cmd/eval.go
index 81351ba..938456c 100644
--- a/cmd/cue/cmd/eval.go
+++ b/cmd/cue/cmd/eval.go
@@ -80,7 +80,7 @@
}
func init() {
- RootCmd.AddCommand(evalCmd)
+ rootCmd.AddCommand(evalCmd)
expressions = evalCmd.Flags().StringArrayP("expression", "e", nil, "evaluate this expression only")
diff --git a/cmd/cue/cmd/export.go b/cmd/cue/cmd/export.go
index 7557eae..26ff01c 100644
--- a/cmd/cue/cmd/export.go
+++ b/cmd/cue/cmd/export.go
@@ -94,7 +94,7 @@
)
func init() {
- RootCmd.AddCommand(exportCmd)
+ rootCmd.AddCommand(exportCmd)
exportCmd.Flags().StringP("output", "o", "json", "output format (json only for now)")
escape = exportCmd.Flags().BoolP("escape", "e", false, "use HTML escaping")
diff --git a/cmd/cue/cmd/fmt.go b/cmd/cue/cmd/fmt.go
index 7ee1fe7..854a972 100644
--- a/cmd/cue/cmd/fmt.go
+++ b/cmd/cue/cmd/fmt.go
@@ -26,7 +26,7 @@
// fmtCmd represents the fmt command
var fmtCmd = &cobra.Command{
Use: "fmt [-s] [packages]",
- Short: "formats CUE configuration files.",
+ Short: "formats CUE configuration files",
Long: `Fmt formats the given files or the files for the given packages in place
`,
RunE: func(cmd *cobra.Command, args []string) error {
@@ -69,5 +69,5 @@
}
func init() {
- RootCmd.AddCommand(fmtCmd)
+ rootCmd.AddCommand(fmtCmd)
}
diff --git a/cmd/cue/cmd/import.go b/cmd/cue/cmd/import.go
index 4b975ba..feb9670 100644
--- a/cmd/cue/cmd/import.go
+++ b/cmd/cue/cmd/import.go
@@ -196,7 +196,7 @@
}
func init() {
- RootCmd.AddCommand(importCmd)
+ rootCmd.AddCommand(importCmd)
out = importCmd.Flags().StringP("out", "o", "", "alternative output or - for stdout")
name = importCmd.Flags().StringP("name", "n", "", "glob filter for file names")
diff --git a/cmd/cue/cmd/root.go b/cmd/cue/cmd/root.go
index db9152a..84d8a45 100644
--- a/cmd/cue/cmd/root.go
+++ b/cmd/cue/cmd/root.go
@@ -40,8 +40,8 @@
var cfgFile string
-// RootCmd represents the base command when called without any subcommands
-var RootCmd = &cobra.Command{
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
Use: "cue",
Short: "cue emits configuration files to user-defined commands.",
Long: `cue evaluates CUE files, an extension of JSON, and sends them
@@ -91,9 +91,9 @@
// TODO: for now we only allow one instance. Eventually, we can allow
// more if they all belong to the same package and we merge them
// before computing commands.
- if cmd, _, err := RootCmd.Find(args); err != nil || cmd == nil {
- tools := buildTools(RootCmd, args[1:])
- addCustom(RootCmd, commandSection, args[0], tools)
+ if cmd, _, err := rootCmd.Find(args); err != nil || cmd == nil {
+ tools := buildTools(rootCmd, args[1:])
+ addCustom(rootCmd, commandSection, args[0], tools)
}
type subSpec struct {
@@ -108,7 +108,7 @@
if sub, ok := sub[args[0]]; ok && len(args) >= 2 {
args = args[1:]
if len(args) == 0 {
- tools := buildTools(RootCmd, args)
+ tools := buildTools(rootCmd, args)
// list available commands
commands := tools.Lookup(sub.name)
i, err := commands.Fields()
@@ -118,7 +118,7 @@
}
return // TODO: will this trigger the help?
}
- tools := buildTools(RootCmd, args[1:])
+ tools := buildTools(rootCmd, args[1:])
_, err := addCustom(sub.cmd, sub.name, args[0], tools)
if err != nil {
log.Printf("%s %q is not defined", sub.name, args[0])
@@ -126,7 +126,7 @@
}
}
}
- if err := RootCmd.Execute(); err != nil {
+ if err := rootCmd.Execute(); err != nil {
// log.Fatal(err)
os.Exit(1)
}
@@ -146,17 +146,17 @@
func init() {
cobra.OnInitialize(initConfig)
- RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cue)")
- RootCmd.PersistentFlags().Bool("root", false, "load a CUE package from its root")
+ rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cue)")
+ rootCmd.PersistentFlags().Bool("root", false, "load a CUE package from its root")
}
var (
- fDebug = RootCmd.PersistentFlags().Bool("debug", false, "give detailed error info")
- fTrace = RootCmd.PersistentFlags().Bool("trace", false, "trace computation")
- fDryrun = RootCmd.PersistentFlags().BoolP("dryrun", "n", false, "only run simulation")
- fPackage = RootCmd.PersistentFlags().StringP("package", "p", "", "CUE package to evaluate")
- fSimplify = RootCmd.PersistentFlags().BoolP("simplify", "s", false, "simplify output")
- fIgnore = RootCmd.PersistentFlags().BoolP("ignore", "i", false, "proceed in the presence of errors")
+ fDebug = rootCmd.PersistentFlags().Bool("debug", false, "give detailed error info")
+ fTrace = rootCmd.PersistentFlags().Bool("trace", false, "trace computation")
+ fDryrun = rootCmd.PersistentFlags().BoolP("dryrun", "n", false, "only run simulation")
+ fPackage = rootCmd.PersistentFlags().StringP("package", "p", "", "CUE package to evaluate")
+ fSimplify = rootCmd.PersistentFlags().BoolP("simplify", "s", false, "simplify output")
+ fIgnore = rootCmd.PersistentFlags().BoolP("ignore", "i", false, "proceed in the presence of errors")
)
// initConfig reads in config file and ENV variables if set.
diff --git a/cmd/cue/cmd/trim.go b/cmd/cue/cmd/trim.go
index 8449b64..f6484cc 100644
--- a/cmd/cue/cmd/trim.go
+++ b/cmd/cue/cmd/trim.go
@@ -91,7 +91,7 @@
}
func init() {
- RootCmd.AddCommand(trimCmd)
+ rootCmd.AddCommand(trimCmd)
fOut = trimCmd.Flags().StringP("out", "o", "", "alternative output or - for stdout")
}