diff --git a/cmd/config.go b/cmd/config.go index 5ae76fcde..3f68c7e93 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "io/ioutil" + "os" "strings" "github.com/CircleCI-Public/circleci-cli/api" @@ -28,6 +29,7 @@ type configOptions struct { // Used to for compatibility with `circleci config validate --path` var configPath string var ignoreDeprecatedImages bool // should we ignore deprecated images warning +var quietOutput bool // Suppress extra diagnostic output var configAnnotations = map[string]string{ "": "The path to your config (use \"-\" for STDIN)", @@ -73,6 +75,7 @@ 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().BoolVarP(&quietOutput, "quiet", "q", false, "Suppress verbose output") validateCommand.PersistentFlags().BoolVar(&ignoreDeprecatedImages, "ignore-deprecated-images", false, "ignores the deprecated images error") if err := validateCommand.PersistentFlags().MarkHidden("config"); err != nil { panic(err) @@ -139,8 +142,9 @@ func validateConfig(opts configOptions, flags *pflag.FlagSet) error { //if no orgId provided use org slug values := pipeline.LocalPipelineValues() - fmt.Println("Validating config with following values") - printValues(values) + if !(quietOutput) { + printValues(values) + } orgID, _ := flags.GetString("org-id") if strings.TrimSpace(orgID) != "" { @@ -197,7 +201,6 @@ func processConfig(opts configOptions, flags *pflag.FlagSet) error { //if no orgId provided use org slug values := pipeline.LocalPipelineValues() - fmt.Println("Processing config with following values") printValues(values) orgID, _ := flags.GetString("org-id") @@ -237,7 +240,8 @@ func migrateConfig(opts configOptions) error { } func printValues(values pipeline.Values) { + fmt.Fprintln(os.Stderr, "Processing config with following values:") for key, value := range values { - fmt.Printf("\t%s:\t%s", key, value) + fmt.Fprintf(os.Stderr, "%-18s %s\n", key + ":", value) } }