Skip to content

Commit

Permalink
fix: input validation on missing --repository option
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanholsteijn committed Aug 3, 2023
1 parent 5529afb commit 840de6a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ Options:
if err = args.Bind(&cru); err != nil {
log.Fatal(err)
}

if cru.Url == "" {
if cru.CommitMsg != "" {
fmt.Fprint(os.Stderr, "ERROR: --repository option is required when specifying a commit message")
os.Exit(1)
}
if cru.Username != "" {
fmt.Fprint(os.Stderr, "ERROR: --repository option is required when specifying a git username")
os.Exit(1)
}
if cru.Email != "" {
fmt.Fprint(os.Stderr, "ERROR: --repository option is required when specifying a git email")
os.Exit(1)
}
}
cru.ApplyDefaults()

if err = cru.ConnectToRepository(); err != nil {
Expand Down

0 comments on commit 840de6a

Please sign in to comment.