diff --git a/internal/commands/root.go b/internal/commands/root.go index d6fb1174a..a440f165c 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -211,7 +211,6 @@ func NewAstCLI( chatCmd, ) - rootCmd.SilenceErrors = true rootCmd.SilenceUsage = true return rootCmd } diff --git a/internal/commands/root_test.go b/internal/commands/root_test.go index ad14bc490..9fee22ce1 100644 --- a/internal/commands/root_test.go +++ b/internal/commands/root_test.go @@ -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)