Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cql2csv -q "select * from system.schema_columns"
## CQL2CSV

```
usage: cql2csv [-c contactpoint] [-q query] [FILE]
usage: cql2csv [-c contactpoint] [-r cassandraPort] [-q query] [FILE]
File The file to use as CQL query. If both FILE and QUERY are
omitted, query will be read from STDIN.

Expand All @@ -57,6 +57,7 @@ File The file to use as CQL query. If both FILE and QUERY are
piping to grep or as a simple primary
key.
-p <arg> The password to authenticate.
-r <arg> The port to connect to Cassandra, defaults to 9042.
-P,--parallel <arg> The level of parallelism to run the
task. Default is sequential.
-q,--query <CQL> The CQL query to execute. If
Expand All @@ -77,7 +78,7 @@ File The file to use as CQL query. If both FILE and QUERY are

## CQL2JSON
```
usage: cql2json [-c contactpoint] [-q query] [FILE]
usage: cql2json [-c contactpoint] [-r cassandraPort] [-q query] [FILE]
File The file to use as CQL query. If both FILE and QUERY are
omitted, query will be read from STDIN.

Expand Down Expand Up @@ -107,6 +108,7 @@ File The file to use as CQL query. If both FILE and QUERY are
piping to grep or as a simple primary
key.
-p <arg> The password to authenticate.
-r <arg> The port to connect to Cassandra, defaults to 9042.
-P,--parallel <arg> The level of parallelism to run the
task. Default is sequential.
-q,--query <CQL> The CQL query to execute. If
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/tenmax/cqlkit/CQL2CQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected void prepareOptions(Options options) {
options.addOption("T", "template", true, "The template of CQL statements. The format is " +
"the same as PreparedStatement.");
options.getOption("T").setRequired(true);
options.addOption( "r", "port", true, "Cassandra Port" );
}

@Override
Expand All @@ -48,7 +49,7 @@ protected void printVersion() {
protected void printHelp(Options options) {
HelpFormatter formatter = new HelpFormatter();
String cmdLineSyntax =
"cql2cql [-c contactpoint] [-q query] [-T template] [FILE]";
"cql2cql [-c contactpoint] [-r CassandraPort] [-q query] [-T template] [FILE]";
String header = "File The file to use as CQL query. If both FILE and QUERY are \n" +
" omitted, query will be read from STDIN.\n\n";
formatter.printHelp(cmdLineSyntax, header, options, null);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/tenmax/cqlkit/CQL2CSV.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected void prepareOptions(Options options) {
super.prepareOptions(options);

options.addOption( "H", "no-header-row", false, "Do not output column names." );
options.addOption( "r", "port", true, "Cassandra Port" );
options.addOption( "l", "linenumbers", false,
"Insert a column of line numbers at the front of the " +
"output. Useful when piping to grep or as a simple " +
Expand All @@ -38,7 +39,7 @@ protected void printVersion() {
protected void printHelp(Options options) {
HelpFormatter formatter = new HelpFormatter();
String cmdLineSyntax =
"cql2csv [-c contactpoint] [-q query] [FILE]";
"cql2csv [-c contactpoint] [-r CassandraPort] [-q query] [FILE]";
String header = "File The file to use as CQL query. If both FILE and QUERY are \n" +
" omitted, query will be read from STDIN.\n\n";
formatter.printHelp(cmdLineSyntax, header, options, null);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/tenmax/cqlkit/CQL2JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected void prepareOptions(Options options) {
"Insert a column of line numbers at the front of the " +
"output. Useful when piping to grep or as a simple " +
"primary key.");
options.addOption( "r", "port", true, "Cassandra Port" );
}

@Override
Expand All @@ -44,7 +45,7 @@ protected void printVersion() {
protected void printHelp(Options options) {
HelpFormatter formatter = new HelpFormatter();
String cmdLineSyntax =
"cql2json [-c contactpoint] [-q query] [FILE]";
"cql2json [-c contactpoint] [-r CassandraPort] [-q query] [FILE]";
String header = "File The file to use as CQL query. If both FILE and QUERY are \n" +
" omitted, query will be read from STDIN.\n\n";
formatter.printHelp(cmdLineSyntax, header, options, null);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/tenmax/cqlkit/SessionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ private SessionFactory(CommandLine commandLine,

Optional<HierarchicalINIConfiguration> rcOpt = Optional.ofNullable(cqlshrc);

int cassandraPort = 9042;

if(commandLine.hasOption("r")) {
cassandraPort = Integer.parseInt(commandLine.getOptionValue("r"));
}

builder.withPort(cassandraPort);

if(commandLine.hasOption("c")) {
builder.addContactPoints(commandLine.getOptionValue("c").split(","));
} else {
Expand Down