diff options
Diffstat (limited to 'cmd/platform/config.go')
-rw-r--r-- | cmd/platform/config.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/cmd/platform/config.go b/cmd/platform/config.go index 6a3df0ade..0b3f26ee0 100644 --- a/cmd/platform/config.go +++ b/cmd/platform/config.go @@ -20,7 +20,8 @@ var configCmd = &cobra.Command{ var validateConfigCmd = &cobra.Command{ Use: "validate", Short: "Validate config file", - Run: configValidateCmdF, + Long: "If the config file is valid, this command will output a success message and have a zero exit code. If it is invalid, this command will output an error and have a non-zero exit code.", + RunE: configValidateCmdF, } func init() { @@ -29,39 +30,35 @@ func init() { ) } -func configValidateCmdF(cmd *cobra.Command, args []string) { +func configValidateCmdF(cmd *cobra.Command, args []string) error { utils.TranslationsPreInit() filePath, err := cmd.Flags().GetString("config") if err != nil { - CommandPrintErrorln(err) - return + return err } filePath = utils.FindConfigFile(filePath) file, err := os.Open(filePath) if err != nil { - CommandPrintErrorln(err) - return + return err } decoder := json.NewDecoder(file) config := model.Config{} err = decoder.Decode(&config) if err != nil { - CommandPrintErrorln(err) - return + return err } if _, err := file.Stat(); err != nil { - CommandPrintErrorln(err) - return + return err } if err := config.IsValid(); err != nil { - CommandPrintErrorln(errors.New(utils.T(err.Id))) - return + return errors.New(utils.T(err.Id)) } CommandPrettyPrintln("The document is valid") + return nil } |