diff --git a/cmd/config.go b/cmd/config.go index a30c82d78..dce808c14 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "net/url" + "os" "strings" "github.com/CircleCI-Public/circleci-cli/api/rest" @@ -33,6 +34,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 verboseOutput bool // Enable extra debugging output var configAnnotations = map[string]string{ "": "The path to your config (use \"-\" for STDIN)", @@ -86,6 +88,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(&verboseOutput, "verbose", "v", false, "Enable 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) @@ -153,8 +156,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 verboseOutput { + printValues(values) + } var orgID string orgID, _ = flags.GetString("org-id") @@ -217,7 +221,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") @@ -262,8 +265,9 @@ 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) } }