Skip to content

Commit

Permalink
style(cli): use switch instead of if statements (#822)
Browse files Browse the repository at this point in the history
I also removed one leftover `fmt.Println()`

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune authored Jun 15, 2022
1 parent 0b1de6a commit e40322c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion cli/cmd/lql.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ func runQuery(cmd *cobra.Command, args []string) error {
queryCmdState.FailOnCount,
len(response.Data),
)
fmt.Println(queryFailonError.ExitCode)
if queryFailonError.NonCompliant() {
cmd.SilenceUsage = true
return queryFailonError
Expand Down
10 changes: 5 additions & 5 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ This will prompt you for your Lacework account and a set of API access keys.`,
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() (err error) {
defer func() {
var vpe *vulnerabilityPolicyError
if errors.As(err, &vpe) {
switch err.(type) {
case *vulnerabilityPolicyError:
vpe := err.(*vulnerabilityPolicyError)
exitwithCode(vpe, vpe.ExitCode)
}
var qfe *queryFailonError
if errors.As(err, &qfe) {
case *queryFailonError:
qfe := err.(*queryFailonError)
exitwithCode(qfe, qfe.ExitCode)
}
}()
Expand Down

0 comments on commit e40322c

Please sign in to comment.