Skip to content

Commit

Permalink
Merge pull request #118 from jkaninda/refactor
Browse files Browse the repository at this point in the history
chore: add command usage error
  • Loading branch information
jkaninda authored Oct 20, 2024
2 parents 29dc9d5 + 3e3084d commit 7ebbcf0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var BackupCmd = &cobra.Command{
if len(args) == 0 {
pkg.StartBackup(cmd)
} else {
utils.Fatal("Error, no argument required")
utils.Fatal(`"backup" accepts no argument %q`, args)

}
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var MigrateCmd = &cobra.Command{
if len(args) == 0 {
pkg.StartMigration(cmd)
} else {
utils.Fatal("Error, no argument required")
utils.Fatal(`"migrate" accepts no argument %q`, args)

}

Expand Down
2 changes: 1 addition & 1 deletion cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var RestoreCmd = &cobra.Command{
if len(args) == 0 {
pkg.StartRestore(cmd)
} else {
utils.Fatal("Error, no argument required")
utils.Fatal(`"restore" accepts no argument %q`, args)

}

Expand Down
4 changes: 4 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,7 @@ func CronNextTime(cronExpr string) time.Time {
//Info("The next scheduled time is: %v\n", 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())
}

0 comments on commit 7ebbcf0

Please sign in to comment.