Skip to content

Commit

Permalink
Move Terraform args check (#22)
Browse files Browse the repository at this point in the history
The check came too early and would hide Cobra's check for required args.

Signed-off-by: Reinhard Nägele <unguiculus@gmail.com>
  • Loading branch information
unguiculus authored Jun 5, 2020
1 parent 9bdf50b commit d177788
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 0 additions & 7 deletions cmd/gotf/gotf.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package gotf

import (
"errors"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -59,12 +58,6 @@ func newGotfCommand() *cobra.Command {
gotf is a Terraform wrapper facilitating configurations for various environments
`, fullVersion),
Version: fullVersion,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("no arguments for Terraform specified")
}
return nil
},
RunE: func(command *cobra.Command, args []string) error {
return gotf.Run(gotf.Args{
Debug: debug,
Expand Down
5 changes: 5 additions & 0 deletions pkg/gotf/gotf.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package gotf

import (
"errors"
"fmt"
"io/ioutil"
"log"
Expand Down Expand Up @@ -80,6 +81,10 @@ type Args struct {
}

func Run(args Args) error {
if len(args.Args) == 0 {
return errors.New("no arguments for Terraform specified")
}

if args.Debug {
log.SetOutput(os.Stderr)
log.SetFlags(0)
Expand Down

0 comments on commit d177788

Please sign in to comment.