Skip to content

Commit

Permalink
Merge pull request #908 from Checkmarx/bug/handlingErrors
Browse files Browse the repository at this point in the history
Return correct exit code on failure (AST-57074)
  • Loading branch information
sarahCx authored Oct 14, 2024
2 parents 7911e3f + 7cdd641 commit 8bcbea2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func NewAstCLI(
chatCmd,
)

rootCmd.SilenceErrors = true
rootCmd.SilenceUsage = true
return rootCmd
}
Expand Down
7 changes: 7 additions & 0 deletions internal/commands/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ func TestFilterTagStateAndSeverityValues(t *testing.T) {
assert.NilError(t, err)
}

func TestCreateCommand_WithInvalidFlag_ShouldReturnExitCode1(t *testing.T) {
args := []string{"g"}
cmd := createASTTestCommand()
err := executeTestCommand(cmd, args...)
assert.Error(t, err, "unknown command \"g\" for \"cx\"")
}

func executeTestCommand(cmd *cobra.Command, args ...string) error {
fmt.Println("Executing command with args ", args)
cmd.SetArgs(args)
Expand Down

0 comments on commit 8bcbea2

Please sign in to comment.