@@ -36,24 +36,32 @@ public class BammCli extends AbstractCommand {
36
36
37
37
public static final String COMMAND_NAME = "bamm" ;
38
38
39
- private final CommandLine commandLine = new CommandLine ( this );
39
+ private final CommandLine commandLine = new CommandLine ( this )
40
+ .addSubcommand ( new AspectCommand () )
41
+ .setCaseInsensitiveEnumValuesAllowed ( true );
40
42
41
43
@ CommandLine .Option ( names = { "--version" }, description = "Show current version" )
42
44
private boolean version ;
43
45
44
- public void run ( final String ... argv ) throws Exception {
45
- main ( argv );
46
+ int run ( final String ... argv ) {
47
+ return commandLine . execute ( argv );
46
48
}
47
49
48
- public static void main ( final String [] argv ) throws Exception {
50
+ int runWithExceptionHandler ( final CommandLine .IExecutionExceptionHandler exceptionHandler , final String ... argv ) {
51
+ final CommandLine .IExecutionExceptionHandler oldHandler = commandLine .getExecutionExceptionHandler ();
52
+ try {
53
+ commandLine .setExecutionExceptionHandler ( exceptionHandler );
54
+ return commandLine .execute ( argv );
55
+ } finally {
56
+ commandLine .setExecutionExceptionHandler ( oldHandler );
57
+ }
58
+ }
59
+
60
+ public static void main ( final String [] argv ) {
49
61
AnsiConsole .systemInstall ();
50
62
51
63
final BammCli command = new BammCli ();
52
- final CommandLine commandLine = command .commandLine
53
- .addSubcommand ( new AspectCommand () )
54
- .setCaseInsensitiveEnumValuesAllowed ( true );
55
-
56
- final int exitCode = commandLine .execute ( argv );
64
+ final int exitCode = command .commandLine .execute ( argv );
57
65
AnsiConsole .systemUninstall ();
58
66
System .exit ( exitCode );
59
67
}
0 commit comments