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

Commit

Permalink
Fixed argument validation
Browse files Browse the repository at this point in the history
  • Loading branch information
eprovst committed Jan 1, 2019
1 parent a815a1f commit 9f99675
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cli/argvalidation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ import (

// validateArguments validates if the combination of flags and arguments is valid
func validateArguments() error {
// If we don't have to do anything special, we need at least one command
if flag.NFlag() == 0 && len(flag.Args()) == 0 {
return errors.New("missing argument: command")
}

// See if we have too many flags
numFlags := flag.NFlag()

// Update and platform don't realy count
if *update {
// The platform flag never counts
if *platform != "" {
numFlags--
}

if *platform != "" {
// If we don't have to do anything special, we need at least one command
if numFlags == 0 && len(flag.Args()) == 0 {
return errors.New("missing argument: command")
}

// The update flag generally doesn't count
if *update {
numFlags--
}

Expand Down

0 comments on commit 9f99675

Please sign in to comment.