11package org .utplsql .cli ;
22
3- import com .beust .jcommander .JCommander ;
4- import com .beust .jcommander .ParameterException ;
53import picocli .CommandLine ;
64
75import java .util .List ;
@@ -10,49 +8,13 @@ public class Cli {
108
119 static final int DEFAULT_ERROR_CODE = 1 ;
1210
13- static final String HELP_CMD = "-h" ;
14-
1511 public static void main (String [] args ) {
1612
1713 int exitCode = runPicocliWithExitCode (args );
1814
1915 System .exit (exitCode );
2016 }
2117
22- static int runWithExitCode ( String [] args ) {
23-
24- LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
25- LocaleInitializer .initLocale ();
26-
27- JCommander jc = new JCommander ();
28- jc .setProgramName ("utplsql" );
29-
30- CommandProvider cmdProvider = new CommandProvider (jc );
31-
32- cmdProvider .commands ().forEach (cmd -> jc .addCommand (cmd .getCommand (), cmd ));
33-
34- int exitCode = DEFAULT_ERROR_CODE ;
35-
36- if ( args .length >= 1 && args [0 ].equals ("-h" ) ) // Help?
37- {
38- exitCode = 0 ;
39- jc .usage ();
40- }
41- else {
42- try {
43- jc .parse (args );
44-
45- exitCode = cmdProvider .getCommand (jc .getParsedCommand ()).run ();
46-
47- } catch (ParameterException e ) {
48- exitCode = new HelpCommand (jc , e .getMessage ()).run ();
49- } catch (Exception e ) {
50- e .printStackTrace ();
51- }
52- }
53-
54- return exitCode ;
55- }
5618 static int runPicocliWithExitCode ( String [] args ) {
5719
5820 LoggerConfiguration .configure (LoggerConfiguration .ConfigLevel .NONE );
0 commit comments