add usage message only when parsing flags failed

This commit is contained in:
sanposhiho 2021-09-22 00:40:15 +09:00
parent 9ff99adc60
commit 77c1949326

View File

@ -49,6 +49,12 @@ func runSchedulerCmd() error {
logs.InitLogs()
defer logs.FlushLogs()
err := command.ParseFlags(os.Args[1:])
if err != nil {
// when fail to parse flags, return error with the usage message.
return fmt.Errorf("%v\n%s", err, command.UsageString())
}
if err := command.Execute(); err != nil {
return err
}