|
1 | 1 | package org.utplsql.cli; |
2 | 2 |
|
3 | | -import com.beust.jcommander.Parameter; |
4 | | -import com.beust.jcommander.Parameters; |
5 | 3 | import org.utplsql.api.exception.DatabaseNotCompatibleException; |
6 | 4 | import org.utplsql.api.exception.UtPLSQLNotInstalledException; |
7 | 5 | import org.utplsql.api.reporter.ReporterFactory; |
8 | 6 | import org.utplsql.api.reporter.inspect.ReporterInfo; |
9 | 7 | import org.utplsql.api.reporter.inspect.ReporterInspector; |
10 | 8 | import org.utplsql.cli.exception.DatabaseConnectionFailed; |
| 9 | +import picocli.CommandLine.*; |
11 | 10 |
|
12 | 11 | import javax.sql.DataSource; |
13 | 12 | import java.io.PrintStream; |
14 | 13 | import java.sql.Connection; |
15 | 14 | import java.util.*; |
16 | 15 |
|
17 | | -@Parameters(separators = "=", commandDescription = "prints a list of reporters available in the specified database") |
| 16 | +@Command( name = "reporters", description = "prints a list of reporters available in the specified database") |
18 | 17 | public class ReportersCommand implements ICommand { |
19 | 18 |
|
20 | | - @Parameter( |
21 | | - converter = ConnectionInfo.ConnectionStringConverter.class, |
22 | | - arity = 1, |
23 | | - description = ConnectionInfo.COMMANDLINE_PARAM_DESCRIPTION) |
24 | | - private List<ConnectionInfo> connectionInfoList = new ArrayList<>(); |
25 | | - |
26 | | - private ConnectionInfo getConnectionInfo() { |
27 | | - Objects.requireNonNull(connectionInfoList); |
28 | | - |
29 | | - if ( connectionInfoList.size() <= 0 |
30 | | - || connectionInfoList.get(0) == null) |
31 | | - throw new IllegalArgumentException("No Connection-Info given"); |
32 | | - |
33 | | - return connectionInfoList.get(0); |
34 | | - } |
| 19 | + @Parameters(description = ConnectionInfo.COMMANDLINE_PARAM_DESCRIPTION, arity = "1") |
| 20 | + private String connectionString; |
35 | 21 |
|
36 | 22 | @Override |
37 | 23 | public int run() { |
38 | 24 |
|
39 | 25 | try { |
40 | | - DataSource ds = DataSourceProvider.getDataSource(getConnectionInfo(), 1); |
| 26 | + DataSource ds = DataSourceProvider.getDataSource(connectionString, 1); |
41 | 27 | try (Connection con = ds.getConnection()) { |
42 | 28 |
|
43 | 29 | ReporterFactory reporterFactory = ReporterFactoryProvider.createReporterFactory(con); |
|
0 commit comments