diff --git a/cmd/admin.go b/cmd/admin.go index bd3e6823b..6d370989b 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -25,9 +25,9 @@ func newAdminCommand(config *settings.Config) *cobra.Command { Args: cobra.MinimumNArgs(1), } importOrbCommand.Flags().BoolVar(&orbOpts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.") - if err := importOrbCommand.Flags().MarkHidden("integration-testing"); err != nil { - panic(err) - } + // if err := importOrbCommand.Flags().MarkHidden("integration-testing"); err != nil { + // panic(err) + // } importOrbCommand.Flags().BoolVar(&orbOpts.noPrompt, "no-prompt", false, "Disable prompt to bypass interactive UI.") renameCommand := &cobra.Command{ @@ -79,9 +79,9 @@ Example: deleteAliasCommand.Annotations[""] = "The name of the alias to delete" deleteAliasCommand.Flags().BoolVar(&nsOpts.noPrompt, "no-prompt", false, "Disable prompt to bypass interactive UI.") deleteAliasCommand.Flags().BoolVar(&nsOpts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.") - if err := deleteAliasCommand.Flags().MarkHidden("integration-testing"); err != nil { - panic(err) - } + // if err := deleteAliasCommand.Flags().MarkHidden("integration-testing"); err != nil { + // panic(err) + // } deleteNamespaceCommand := &cobra.Command{ Use: "delete-namespace ", @@ -110,7 +110,7 @@ Example: adminCommand := &cobra.Command{ Use: "admin", - Short: "Administrative operations for a CircleCI Server installation.", + Short: "Administrative operations for a CircleCI Server installation. (hidden)", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { orbOpts.args = args nsOpts.args = args @@ -122,7 +122,7 @@ Example: // As of writing this comment, that is only for daily update checks. return rootCmdPreRun(rootOptions) }, - Hidden: true, + Hidden: false, } adminCommand.AddCommand(importOrbCommand) diff --git a/cmd/build.go b/cmd/build.go index 96fa77510..3dc367bf4 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -24,8 +24,8 @@ func newLocalExecuteCommand(config *settings.Config) *cobra.Command { // hidden command for backwards compatibility func newBuildCommand(config *settings.Config) *cobra.Command { cmd := newLocalExecuteCommand(config) - cmd.Hidden = true - cmd.Use = "build" + cmd.Hidden = false + cmd.Use = "build (hidden)" return cmd } diff --git a/cmd/config.go b/cmd/config.go index b293ff787..996b97cf6 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "io/ioutil" + "strings" "github.com/CircleCI-Public/circleci-cli/api" "github.com/CircleCI-Public/circleci-cli/api/graphql" @@ -73,9 +74,6 @@ func newConfigCommand(config *settings.Config) *cobra.Command { validateCommand.Annotations[""] = configAnnotations[""] validateCommand.PersistentFlags().StringVarP(&configPath, "config", "c", ".circleci/config.yml", "path to config file") validateCommand.PersistentFlags().BoolVar(&ignoreDeprecatedImages, "ignore-deprecated-images", false, "ignores the deprecated images error") - if err := validateCommand.PersistentFlags().MarkHidden("config"); err != nil { - panic(err) - } validateCommand.Flags().StringP("org-slug", "o", "", "organization slug (for example: github/example-org), used when a config depends on private orbs belonging to that org") processCommand := &cobra.Command{ @@ -97,14 +95,13 @@ func newConfigCommand(config *settings.Config) *cobra.Command { migrateCommand := &cobra.Command{ Use: "migrate", - Short: "Migrate a pre-release 2.0 config to the official release version", + Short: "Migrate a pre-release 2.0 config to the official release version (hidden)", PreRun: func(cmd *cobra.Command, args []string) { opts.args = args }, RunE: func(_ *cobra.Command, _ []string) error { return migrateConfig(opts) }, - Hidden: true, DisableFlagParsing: true, } // These flags are for documentation and not actually parsed @@ -193,11 +190,13 @@ func packConfig(opts configOptions) error { return errors.Wrap(err, "An error occurred trying to build the tree") } - y, err := yaml.Marshal(&tree) - if err != nil { + var s strings.Builder + enc := yaml.NewEncoder(&s) + enc.SetIndent(2) + if err := enc.Encode(&tree); err != nil { return errors.Wrap(err, "Failed trying to marshal the tree to YAML ") } - fmt.Printf("%s\n", string(y)) + fmt.Print(s.String()) return nil } diff --git a/cmd/namespace.go b/cmd/namespace.go index 69b9728f3..7e1e9a4f5 100644 --- a/cmd/namespace.go +++ b/cmd/namespace.go @@ -82,7 +82,7 @@ Please note that at this time all namespaces created in the registry are world-r createCmd.Annotations[""] = `Your VCS provider, can be either "github" or "bitbucket"` createCmd.Annotations[""] = `The name used for your organization` - createCmd.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.") + createCmd.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI. (hidden)") if err := createCmd.Flags().MarkHidden("integration-testing"); err != nil { panic(err) } diff --git a/cmd/orb.go b/cmd/orb.go index 11cfef643..bdf887aec 100644 --- a/cmd/orb.go +++ b/cmd/orb.go @@ -102,12 +102,12 @@ func newOrbCommand(config *settings.Config) *cobra.Command { listCommand.PersistentFlags().StringVar(&opts.sortBy, "sort", "", `one of "builds"|"projects"|"orgs"`) listCommand.PersistentFlags().BoolVarP(&opts.listUncertified, "uncertified", "u", false, "include uncertified orbs") - listCommand.PersistentFlags().BoolVar(&opts.listJSON, "json", false, "print output as json instead of human-readable") + listCommand.PersistentFlags().BoolVar(&opts.listJSON, "json", false, "print output as json instead of human-readable (hidden)") listCommand.PersistentFlags().BoolVarP(&opts.listDetails, "details", "d", false, "output all the commands, executors, and jobs, along with a tree of their parameters") listCommand.PersistentFlags().BoolVarP(&opts.private, "private", "", false, "exclusively list private orbs within a namespace") - if err := listCommand.PersistentFlags().MarkHidden("json"); err != nil { - panic(err) - } + // if err := listCommand.PersistentFlags().MarkHidden("json"); err != nil { + // panic(err) + // } validateCommand := &cobra.Command{ Use: "validate ", @@ -285,10 +285,10 @@ Please note that at this time all orbs created in the registry are world-readabl }, } - listCategoriesCommand.PersistentFlags().BoolVar(&opts.listJSON, "json", false, "print output as json instead of human-readable") - if err := listCategoriesCommand.PersistentFlags().MarkHidden("json"); err != nil { - panic(err) - } + listCategoriesCommand.PersistentFlags().BoolVar(&opts.listJSON, "json", false, "print output as json instead of human-readable (hidden)") + // if err := listCategoriesCommand.PersistentFlags().MarkHidden("json"); err != nil { + // panic(err) + // } addCategorizationToOrbCommand := &cobra.Command{ Use: "add-to-category / \"\"", @@ -319,10 +319,10 @@ Please note that at this time all orbs created in the registry are world-readabl } orbInit.PersistentFlags().BoolVarP(&opts.private, "private", "", false, "initialize a private orb") - orbCreate.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.") - if err := orbCreate.Flags().MarkHidden("integration-testing"); err != nil { - panic(err) - } + orbCreate.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI. (hidden)") + // if err := orbCreate.Flags().MarkHidden("integration-testing"); err != nil { + // panic(err) + // } orbCreate.Flags().BoolVar(&opts.noPrompt, "no-prompt", false, "Disable prompt to bypass interactive UI.") orbCommand := &cobra.Command{ @@ -987,13 +987,15 @@ func packOrb(path string) (string, error) { return "", errors.Wrap(err, "An unexpected error occurred") } - y, err := yaml.Marshal(&tree) - if err != nil { + var buf bytes.Buffer + enc := yaml.NewEncoder(&buf) + enc.SetIndent(2) + if err := enc.Encode(&tree); err != nil { return "", errors.Wrap(err, "An unexpected error occurred") } var orbSchema OrbSchema - err = yaml.Unmarshal(y, &orbSchema) + err = yaml.Unmarshal(buf.Bytes(), &orbSchema) if err != nil { return "", errors.Wrap(err, "An unexpected error occurred") } @@ -1011,12 +1013,12 @@ func packOrb(path string) (string, error) { return "", err } - final, err := yaml.Marshal(&orbSchema) - if err != nil { + buf.Reset() + if err := enc.Encode(&orbSchema); err != nil { return "", errors.Wrap(err, "Failed trying to marshal Orb YAML") } - return string(final), nil + return buf.String(), nil } // Travel down a YAML node, replacing values as we go. diff --git a/cmd/orb_test.go b/cmd/orb_test.go index 8d0b89cb6..b5d004c3f 100644 --- a/cmd/orb_test.go +++ b/cmd/orb_test.go @@ -3332,11 +3332,11 @@ Windows Server 2010 Expect(err).ShouldNot(HaveOccurred()) Eventually(session.Out).Should(gbytes.Say(`commands: - orb: - steps: - - run: - command: echo Hello, world! - name: Say hello + orb: + steps: + - run: + command: echo Hello, world! + name: Say hello `)) Eventually(session).Should(gexec.Exit(0)) }) diff --git a/cmd/query.go b/cmd/query.go index 14a833642..e541c53f7 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -25,8 +25,8 @@ func newQueryCommand(config *settings.Config) *cobra.Command { queryCommand := &cobra.Command{ Use: "query ", - Short: "Query the CircleCI GraphQL API.", - Hidden: true, + Short: "Query the CircleCI GraphQL API. (hidden)", + Hidden: false, PreRunE: func(_ *cobra.Command, args []string) error { opts.args = args opts.cl = graphql.NewClient(config.HTTPClient, config.Host, config.Endpoint, config.Token, config.Debug) diff --git a/cmd/root.go b/cmd/root.go index 3b1a7d276..4b38560aa 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -158,11 +158,11 @@ func MakeCommands() *cobra.Command { flags := rootCmd.PersistentFlags() - flags.BoolVar(&rootOptions.Debug, "debug", rootOptions.Debug, "Enable debug logging.") + flags.BoolVar(&rootOptions.Debug, "debug", rootOptions.Debug, "Enable debug logging. (hidden)") flags.StringVar(&rootTokenFromFlag, "token", "", "your token for using CircleCI, also CIRCLECI_CLI_TOKEN") flags.StringVar(&rootOptions.Host, "host", rootOptions.Host, "URL to your CircleCI host, also CIRCLECI_CLI_HOST") - flags.StringVar(&rootOptions.Endpoint, "endpoint", rootOptions.Endpoint, "URI to your CircleCI GraphQL API endpoint") - flags.StringVar(&rootOptions.GitHubAPI, "github-api", "https://api.github.com/", "Change the default endpoint to GitHub API for retrieving updates") + flags.StringVar(&rootOptions.Endpoint, "endpoint", rootOptions.Endpoint, "URI to your CircleCI GraphQL API endpoint (hidden)") + flags.StringVar(&rootOptions.GitHubAPI, "github-api", "https://api.github.com/", "Change the default endpoint to GitHub API for retrieving updates (hidden)") flags.BoolVar(&rootOptions.SkipUpdateCheck, "skip-update-check", skipUpdateByDefault(), "Skip the check for updates check run before every command.") hidden := []string{"github-api", "debug", "endpoint"} diff --git a/cmd/setup.go b/cmd/setup.go index 6a2d068b5..b9e4b1f65 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -141,22 +141,22 @@ func newSetupCommand(config *settings.Config) *cobra.Command { }, } - setupCommand.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.") - if err := setupCommand.Flags().MarkHidden("integration-testing"); err != nil { - panic(err) - } + setupCommand.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI. (hidden)") + // if err := setupCommand.Flags().MarkHidden("integration-testing"); err != nil { + // panic(err) + // } setupCommand.Flags().BoolVar(&opts.noPrompt, "no-prompt", false, "Disable prompt to bypass interactive UI. (MUST supply --host and --token)") - setupCommand.Flags().StringVar(&opts.host, "host", "", "URL to your CircleCI host") - if err := setupCommand.Flags().MarkHidden("host"); err != nil { - panic(err) - } + setupCommand.Flags().StringVar(&opts.host, "host", "", "URL to your CircleCI host (hidden)") + // if err := setupCommand.Flags().MarkHidden("host"); err != nil { + // panic(err) + // } - setupCommand.Flags().StringVar(&opts.token, "token", "", "your token for using CircleCI") - if err := setupCommand.Flags().MarkHidden("token"); err != nil { - panic(err) - } + setupCommand.Flags().StringVar(&opts.token, "token", "", "your token for using CircleCI (hidden)") + // if err := setupCommand.Flags().MarkHidden("token"); err != nil { + // panic(err) + // } return setupCommand } diff --git a/cmd/step.go b/cmd/step.go index 3ec717cb2..f514eca75 100644 --- a/cmd/step.go +++ b/cmd/step.go @@ -18,21 +18,21 @@ func newStepCommand(config *settings.Config) *cobra.Command { stepCmd := &cobra.Command{ Use: "step", - Short: "Execute steps", - Hidden: true, + Short: "Execute steps (hidden)", + Hidden: false, DisableFlagParsing: true, } haltCmd := &cobra.Command{ Use: "halt", - Short: "Halt the current job and treat it as successful", + Short: "Halt the current job and treat it as successful (hidden)", PreRun: func(cmd *cobra.Command, args []string) { opts.args = args }, RunE: func(_ *cobra.Command, _ []string) error { return haltRunE(opts) }, - Hidden: true, + Hidden: false, DisableFlagParsing: true, } diff --git a/cmd/switch.go b/cmd/switch.go index b3ff04f31..4ad0b3488 100644 --- a/cmd/switch.go +++ b/cmd/switch.go @@ -18,14 +18,14 @@ func newSwitchCommand(config *settings.Config) *cobra.Command { } return &cobra.Command{ - Use: "switch", + Use: "switch (hidden)", PreRun: func(cmd *cobra.Command, args []string) { opts.args = args }, RunE: func(_ *cobra.Command, _ []string) error { return runSwitch(opts) }, - Hidden: true, + Hidden: false, } } diff --git a/cmd/tests.go b/cmd/tests.go index 7b465f427..be9fab281 100644 --- a/cmd/tests.go +++ b/cmd/tests.go @@ -8,9 +8,9 @@ import ( func newTestsCommand() *cobra.Command { testsCmd := &cobra.Command{ Use: "tests", - Short: "Collect and split tests so they may be run in parallel.", + Short: "Collect and split tests so they may be run in parallel. (hidden)", DisableFlagParsing: true, - Hidden: true, + Hidden: false, RunE: func(_ *cobra.Command, args []string) error { return proxy.Exec([]string{"tests"}, args) }, diff --git a/cmd/update.go b/cmd/update.go index 07f3be75f..ca6d003ab 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -42,8 +42,8 @@ func newUpdateCommand(config *settings.Config) *cobra.Command { update.AddCommand(&cobra.Command{ Use: "check", - Hidden: true, - Short: "Check if there are any updates available", + Hidden: false, + Short: "Check if there are any updates available (hidden)", PersistentPreRun: func(_ *cobra.Command, _ []string) { opts.cfg.SkipUpdateCheck = true }, @@ -58,8 +58,8 @@ func newUpdateCommand(config *settings.Config) *cobra.Command { update.AddCommand(&cobra.Command{ Use: "install", - Hidden: true, - Short: "Update the tool to the latest version", + Hidden: false, + Short: "Update the tool to the latest version (hidden)", PersistentPreRun: func(_ *cobra.Command, _ []string) { opts.cfg.SkipUpdateCheck = true }, @@ -73,8 +73,8 @@ func newUpdateCommand(config *settings.Config) *cobra.Command { update.AddCommand(&cobra.Command{ Use: "build-agent", - Hidden: true, - Short: "Update the build agent to the latest version", + Hidden: false, + Short: "Update the build agent to the latest version (hidden)", PersistentPreRun: func(_ *cobra.Command, _ []string) { opts.cfg.SkipUpdateCheck = true }, diff --git a/cmd/usage.go b/cmd/usage.go index 71feb0e22..6ccf6e159 100644 --- a/cmd/usage.go +++ b/cmd/usage.go @@ -24,8 +24,8 @@ func newUsageCommand(config *settings.Config) *cobra.Command { return &cobra.Command{ Use: "usage (default is \"docs\")", - Short: "Generate usage documentation in markdown for the CLI.", - Hidden: true, + Short: "Generate usage documentation in markdown for the CLI. (hidden)", + Hidden: false, PreRun: func(cmd *cobra.Command, args []string) { opts.args = args },