Skip to content

Commit 2ce4e91

Browse files
committed
Change ReportersCommand to Picocli
1 parent 00f3f5f commit 2ce4e91

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/main/java/org/utplsql/cli/ReportersCommand.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,29 @@
11
package org.utplsql.cli;
22

3-
import com.beust.jcommander.Parameter;
4-
import com.beust.jcommander.Parameters;
53
import org.utplsql.api.exception.DatabaseNotCompatibleException;
64
import org.utplsql.api.exception.UtPLSQLNotInstalledException;
75
import org.utplsql.api.reporter.ReporterFactory;
86
import org.utplsql.api.reporter.inspect.ReporterInfo;
97
import org.utplsql.api.reporter.inspect.ReporterInspector;
108
import org.utplsql.cli.exception.DatabaseConnectionFailed;
9+
import picocli.CommandLine.*;
1110

1211
import javax.sql.DataSource;
1312
import java.io.PrintStream;
1413
import java.sql.Connection;
1514
import java.util.*;
1615

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")
1817
public class ReportersCommand implements ICommand {
1918

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;
3521

3622
@Override
3723
public int run() {
3824

3925
try {
40-
DataSource ds = DataSourceProvider.getDataSource(getConnectionInfo(), 1);
26+
DataSource ds = DataSourceProvider.getDataSource(connectionString, 1);
4127
try (Connection con = ds.getConnection()) {
4228

4329
ReporterFactory reporterFactory = ReporterFactoryProvider.createReporterFactory(con);

src/main/java/org/utplsql/cli/UtplsqlPicocliCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
description = "utPLSQL cli",
88
subcommands = {
99
RunPicocliCommand.class,
10-
VersionInfoCommand.class
10+
VersionInfoCommand.class,
11+
ReportersCommand.class
1112
})
1213
public class UtplsqlPicocliCommand {
1314

0 commit comments

Comments
 (0)