11package org .utplsql .cli ;
22
33
4- import com .beust .jcommander .Parameter ;
5- import com .beust .jcommander .Parameters ;
64import org .utplsql .api .JavaApiVersionInfo ;
75import org .utplsql .api .Version ;
86import org .utplsql .api .db .DefaultDatabaseInformation ;
97import org .utplsql .api .exception .UtPLSQLNotInstalledException ;
8+ import picocli .CommandLine .Command ;
9+ import picocli .CommandLine .Parameters ;
1010
1111import javax .sql .DataSource ;
1212import java .sql .Connection ;
1313import java .sql .SQLException ;
14- import java .util .ArrayList ;
15- import java .util .List ;
1614
17- @ Parameters ( separators = "= " , commandDescription = "prints version information of cli, java-api and - if connection is given - database utPLSQL framework" )
15+ @ Command ( name = "info " , description = "prints version information of cli, java-api and - if connection is given - database utPLSQL framework" )
1816public class VersionInfoCommand implements ICommand {
1917
20- @ Parameter (
21- converter = ConnectionInfo .ConnectionStringConverter .class ,
22- variableArity = true ,
23- description = ConnectionInfo .COMMANDLINE_PARAM_DESCRIPTION )
24- private List <ConnectionInfo > connectionInfoList = new ArrayList <>();
25-
26- private ConnectionInfo getConnectionInfo () {
27- if ( connectionInfoList != null && connectionInfoList .size () > 0 )
28- return connectionInfoList .get (0 );
29- else
30- return null ;
31- }
18+ @ Parameters (description = ConnectionInfo .COMMANDLINE_PARAM_DESCRIPTION , arity = "0..1" )
19+ private String connectionString ;
3220
3321 public int run () {
3422
3523 System .out .println (CliVersionInfo .getInfo ());
3624 System .out .println (JavaApiVersionInfo .getInfo ());
3725
3826 try {
39- writeUtPlsqlVersion (getConnectionInfo () );
27+ writeUtPlsqlVersion (connectionString );
4028 }
4129 catch (SQLException e ) {
4230 e .printStackTrace ();
@@ -46,10 +34,10 @@ public int run() {
4634 return 0 ;
4735 }
4836
49- private void writeUtPlsqlVersion ( ConnectionInfo ci ) throws SQLException {
50- if ( ci != null ) {
37+ private void writeUtPlsqlVersion ( String connectString ) throws SQLException {
38+ if ( connectString != null ) {
5139
52- DataSource dataSource = DataSourceProvider .getDataSource (ci , 1 );
40+ DataSource dataSource = DataSourceProvider .getDataSource (connectString , 1 );
5341
5442 try (Connection con = dataSource .getConnection ()) {
5543 Version v = new DefaultDatabaseInformation ().getUtPlsqlFrameworkVersion (con );
0 commit comments