Skip to content

Commit

Permalink
catch arg errors early
Browse files Browse the repository at this point in the history
  • Loading branch information
esilva-everbridge committed Jan 15, 2019
1 parent 847fbdc commit 020aae5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ var decryptCmd = &cobra.Command{
logger.Fatal(err)
}

if len(args) == 0 {
cmd.Help()
return
}

// process args
switch args[0] {
case all:
Expand All @@ -65,7 +70,7 @@ var decryptCmd = &cobra.Command{
s := sls.New(inputFilePath, pk, topLevelElement)
utils.PathAction(&s, yamlPath, "decrypt")
default:
logger.Fatalf("unknown argument: '%s'", args[0])
cmd.Help()
}
},
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ var encryptCmd = &cobra.Command{
logger.Fatal(err)
}

if len(args) == 0 {
cmd.Help()
return
}

// process args
switch args[0] {
case all:
Expand All @@ -65,7 +70,7 @@ var encryptCmd = &cobra.Command{
s := sls.New(inputFilePath, pk, topLevelElement)
utils.PathAction(&s, yamlPath, "encrypt")
default:
logger.Fatalf("unknown argument: '%s'", args[0])
cmd.Help()
}
},
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ var rotateCmd = &cobra.Command{
s := sls.New(inputFilePath, pk, topLevelElement)
buf, err := s.PerformAction("rotate")
utils.SafeWrite(buf, outputFilePath, err)
} else {
cmd.Help()
}
},
}
Expand Down

0 comments on commit 020aae5

Please sign in to comment.