Merge pull request #118 from jkaninda/refactor
chore: add command usage error
This commit is contained in:
@@ -20,7 +20,8 @@ var BackupCmd = &cobra.Command{
|
|||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
pkg.StartBackup(cmd)
|
pkg.StartBackup(cmd)
|
||||||
} else {
|
} else {
|
||||||
utils.Fatal("Error, no argument required")
|
utils.Fatal(`"backup" accepts no argument %q`, args)
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var MigrateCmd = &cobra.Command{
|
|||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
pkg.StartMigration(cmd)
|
pkg.StartMigration(cmd)
|
||||||
} else {
|
} else {
|
||||||
utils.Fatal("Error, no argument required")
|
utils.Fatal(`"migrate" accepts no argument %q`, args)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ var RestoreCmd = &cobra.Command{
|
|||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
pkg.StartRestore(cmd)
|
pkg.StartRestore(cmd)
|
||||||
} else {
|
} else {
|
||||||
utils.Fatal("Error, no argument required")
|
utils.Fatal(`"restore" accepts no argument %q`, args)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,3 +213,7 @@ func CronNextTime(cronExpr string) time.Time {
|
|||||||
//Info("The next scheduled time is: %v\n", next)
|
//Info("The next scheduled time is: %v\n", next)
|
||||||
return next
|
return next
|
||||||
}
|
}
|
||||||
|
func UsageErrorf(cmd *cobra.Command, message string, args ...interface{}) error {
|
||||||
|
msg := fmt.Sprintf(message, args...)
|
||||||
|
return fmt.Errorf("%s\nSee '%s -h' for help and examples", msg, cmd.CommandPath())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user