Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Add flag counter validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 28, 2023
1 parent 09006c1 commit 2a94718
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/nixpkgs-url/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ $ nixpkgs-url -version`
flag.Usage()
}

detectFlags := []bool{*lastFlag, *targetFlag, *currentFlag}
givenFlagsCount := 0
for _, fg := range detectFlags {
if fg {
givenFlagsCount += 1
}
}

if givenFlagsCount != 1 {
log.Fatalf("`detect` subcommand called with %d flags, but it accepts just one flag", givenFlagsCount)
}

if *lastFlag {
last, err := nixurl.GetLastVersion()
if err != nil {
Expand Down

0 comments on commit 2a94718

Please sign in to comment.