Skip to content

Commit da42290

Browse files
committed
cqlsh fully functional and fix build
1 parent 695af2b commit da42290

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+568
-323
lines changed

astra-shell/NOTES.MD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Generate the Asset (for now)
33

44
```
5-
mvn package -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
5+
mvn package -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
6+
cp ./target/astra-shell-0.3.2-SNAPSHOT-shaded.jar ~/.astra/cli/astra-shell.jar
67
```
78

89
# Executing the command

astra-shell/src/main/java/com/datastax/astra/shell/AstraCli.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
package com.datastax.astra.shell;
22

3+
import java.io.File;
4+
35
import org.fusesource.jansi.AnsiConsole;
46

57
import com.datastax.astra.shell.cmd.HelpCommand;
68
import com.datastax.astra.shell.cmd.config.ConfigCreate;
79
import com.datastax.astra.shell.cmd.config.ConfigDefault;
810
import com.datastax.astra.shell.cmd.config.ConfigDelete;
911
import com.datastax.astra.shell.cmd.config.ConfigList;
10-
import com.datastax.astra.shell.cmd.config.ConfigShow;
12+
import com.datastax.astra.shell.cmd.config.ConfigGet;
1113
import com.datastax.astra.shell.cmd.config.ConfigSetup;
14+
import com.datastax.astra.shell.cmd.db.DbCqlShellCli;
1215
import com.datastax.astra.shell.cmd.db.DbCreateCli;
1316
import com.datastax.astra.shell.cmd.db.DbDeleteCli;
1417
import com.datastax.astra.shell.cmd.db.DbListCli;
15-
import com.datastax.astra.shell.cmd.db.DbShow;
18+
import com.datastax.astra.shell.cmd.db.DbGetCli;
1619
import com.datastax.astra.shell.cmd.db.OperationsDb;
1720
import com.datastax.astra.shell.cmd.iam.RoleListCli;
18-
import com.datastax.astra.shell.cmd.iam.RoleShowCli;
21+
import com.datastax.astra.shell.cmd.iam.RoleGetCli;
1922
import com.datastax.astra.shell.cmd.iam.UserDeleteCli;
2023
import com.datastax.astra.shell.cmd.iam.UserInviteCli;
2124
import com.datastax.astra.shell.cmd.iam.UserListCli;
22-
import com.datastax.astra.shell.cmd.iam.UserShowCli;
25+
import com.datastax.astra.shell.cmd.iam.UserGetCli;
2326
import com.datastax.astra.shell.cmd.shell.ShellCommand;
24-
import com.datastax.astra.shell.utils.LoggerShell;
27+
import com.datastax.astra.shell.out.LoggerShell;
2528
import com.github.rvesse.airline.annotations.Cli;
2629
import com.github.rvesse.airline.annotations.Group;
2730
import com.github.rvesse.airline.parser.errors.ParseArgumentsUnexpectedException;
@@ -43,24 +46,25 @@
4346
groups = {
4447
@Group(name = OperationsDb.DB, description = "Manage databases", commands = {
4548
DbCreateCli.class,
49+
DbCqlShellCli.class,
4650
DbDeleteCli.class,
51+
DbGetCli.class,
4752
DbListCli.class,
48-
DbShow.class
4953
}),
5054
@Group(name = "config", description = "Manage configuration file", commands = {
5155
ConfigCreate.class,
5256
ConfigDefault.class,
5357
ConfigDelete.class,
54-
ConfigShow.class,
58+
ConfigGet.class,
5559
ConfigList.class
5660
}),
5761
@Group(name= "role", description = "Manage roles (RBAC)", commands = {
5862
RoleListCli.class,
59-
RoleShowCli.class
63+
RoleGetCli.class
6064
}),
6165
@Group(name= "user", description = "Manage users", commands = {
6266
UserListCli.class,
63-
UserShowCli.class,
67+
UserGetCli.class,
6468
UserInviteCli.class,
6569
UserDeleteCli.class
6670
}),
@@ -72,6 +76,18 @@
7276
})
7377
public class AstraCli {
7478

79+
/** Environment variable coding user home. */
80+
public static final String ENV_USER_HOME = "user.home";
81+
82+
/** Path to save third-parties. */
83+
public static final String ASTRA_HOME = System.getProperty(ENV_USER_HOME) + File.separator + ".astra";
84+
85+
/** Folder name where to download SCB. */
86+
public static final String SCB_FOLDER = "scb";
87+
88+
/** Folder name to download archives */
89+
public static final String TMP_FOLDER = "tmp";
90+
7591
/**
7692
* Main Program.
7793
*
@@ -94,6 +110,7 @@ public static void main(String[] args) {
94110
.run(); // Run the command
95111

96112
} catch(ParseArgumentsUnexpectedException ex) {
113+
97114
LoggerShell.error("Invalid command: " + ex.getMessage());
98115
//ex.printStackTrace();
99116
} catch(Exception e) {

astra-shell/src/main/java/com/datastax/astra/shell/AstraShell.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
import com.datastax.astra.shell.cmd.QuitCommand;
66
import com.datastax.astra.shell.cmd.db.DbCreateShell;
77
import com.datastax.astra.shell.cmd.db.DbDeleteShell;
8+
import com.datastax.astra.shell.cmd.db.DbGetShell;
89
import com.datastax.astra.shell.cmd.db.DbListShell;
910
import com.datastax.astra.shell.cmd.db.DbUseShell;
1011
import com.datastax.astra.shell.cmd.db.OperationsDb;
1112
import com.datastax.astra.shell.cmd.iam.RoleListShell;
12-
import com.datastax.astra.shell.cmd.iam.RoleShowCli;
13+
import com.datastax.astra.shell.cmd.iam.RoleGetCli;
1314
import com.datastax.astra.shell.cmd.iam.UserDeleteShell;
1415
import com.datastax.astra.shell.cmd.iam.UserInviteShell;
1516
import com.datastax.astra.shell.cmd.iam.UserListShell;
16-
import com.datastax.astra.shell.cmd.iam.UserShowShell;
17+
import com.datastax.astra.shell.cmd.iam.UserGetShell;
1718
import com.datastax.astra.shell.cmd.shell.ConnectCommand;
18-
import com.datastax.astra.shell.cmd.shell.CqlShCommand;
1919
import com.datastax.astra.shell.cmd.shell.EmptyCommand;
20-
import com.datastax.astra.shell.utils.LoggerShell;
20+
import com.datastax.astra.shell.out.LoggerShell;
2121
import com.github.rvesse.airline.annotations.Cli;
2222
import com.github.rvesse.airline.annotations.Group;
2323
import com.github.rvesse.airline.parser.errors.ParseArgumentsUnexpectedException;
@@ -37,23 +37,23 @@
3737
EmptyCommand.class,
3838
HelpCommand.class,
3939
ExitCommand.class,
40-
QuitCommand.class,
41-
CqlShCommand.class
40+
QuitCommand.class
4241
},
4342
groups = {
4443
@Group(name = OperationsDb.DB, description = "Commands acting of database", commands = {
4544
DbCreateShell.class,
4645
DbDeleteShell.class,
4746
DbListShell.class,
47+
DbGetShell.class,
4848
DbUseShell.class
4949
}),
5050
@Group(name= "role", description = "Manage the roles (RBAC)", commands = {
5151
RoleListShell.class,
52-
RoleShowCli.class
52+
RoleGetCli.class
5353
}),
5454
@Group(name= "user", description = "Manage the users permission", commands = {
5555
UserListShell.class,
56-
UserShowShell.class,
56+
UserGetShell.class,
5757
UserInviteShell.class,
5858
UserDeleteShell.class
5959
})

astra-shell/src/main/java/com/datastax/astra/shell/ShellContext.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import com.datastax.astra.shell.cmd.BaseCliCommand;
2020
import com.datastax.astra.shell.cmd.BaseCommand;
2121
import com.datastax.astra.shell.cmd.BaseShellCommand;
22-
import com.datastax.astra.shell.output.OutputFormat;
23-
import com.datastax.astra.shell.utils.LoggerShell;
24-
import com.datastax.astra.shell.utils.ShellPrinter;
22+
import com.datastax.astra.shell.out.LoggerShell;
23+
import com.datastax.astra.shell.out.OutputFormat;
24+
import com.datastax.astra.shell.out.ShellPrinter;
2525

2626
/**
2727
* Hold the context of CLI to know where we are.
@@ -180,7 +180,7 @@ public void init(BaseCliCommand cli) {
180180
}
181181

182182
if (token != null) {
183-
LoggerShell.debug("Token: " + token);
183+
LoggerShell.debug("Token: " + token.substring(0, 20) + "...");
184184
connect(token);
185185
} else {
186186
INVALID_PARAMETER.exit();
@@ -341,8 +341,8 @@ public OutputFormat getOutputFormat() {
341341
BaseCliCommand cli = getStartCommand();
342342
BaseShellCommand sh = getCurrentShellCommand();
343343
if (cli == null) return OutputFormat.human;
344-
if (sh != null) return sh.getFormat();
345-
return cli.getFormat();
344+
if (sh != null) return sh.getOutput();
345+
return cli.getOutput();
346346
}
347347

348348
/**

astra-shell/src/main/java/com/datastax/astra/shell/cmd/BaseCommand.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.datastax.astra.shell.cmd;
22

3-
import com.datastax.astra.shell.output.OutputFormat;
3+
import com.datastax.astra.shell.out.OutputFormat;
44
import com.github.rvesse.airline.annotations.Option;
55

66
/**
@@ -17,7 +17,7 @@ public abstract class BaseCommand implements Runnable {
1717
public static final String DELETE = "delete";
1818

1919
/** Command constants. */
20-
public static final String SHOW = "show";
20+
public static final String GET = "get";
2121

2222
/** Command constants. */
2323
public static final String LIST = "list";
@@ -30,7 +30,7 @@ public abstract class BaseCommand implements Runnable {
3030
/**
3131
* Each command can have a verbose mode.
3232
**/
33-
@Option(name = { "--verbose" }, description = "Enter Debug mode")
33+
@Option(name = { "-v","--verbose" }, description = "Verbose mode with log in console")
3434
protected boolean verbose = false;
3535

3636
/**
@@ -42,19 +42,19 @@ public abstract class BaseCommand implements Runnable {
4242
/**
4343
* No log but provide output as a JSON
4444
*/
45-
@Option(name = { "-f", "--format" },
45+
@Option(name = { "-o", "--output" },
4646
title = "FORMAT",
4747
description = "Output format, valid values are: human,json,csv")
48-
protected OutputFormat format = OutputFormat.human;
48+
protected OutputFormat output = OutputFormat.human;
4949

5050
/**
5151
* Getter accessor for attribute 'format'.
5252
*
5353
* @return
5454
* current value of 'format'
5555
*/
56-
public OutputFormat getFormat() {
57-
return format;
56+
public OutputFormat getOutput() {
57+
return output;
5858
}
5959

6060
/**

astra-shell/src/main/java/com/datastax/astra/shell/cmd/BaseShellCommand.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.datastax.astra.shell.ExitCode;
44
import com.datastax.astra.shell.ShellContext;
5-
import com.datastax.astra.shell.utils.LoggerShell;
6-
import com.datastax.astra.shell.utils.ShellPrinter;
5+
import com.datastax.astra.shell.out.LoggerShell;
6+
import com.datastax.astra.shell.out.ShellPrinter;
77

88
/**
99
* Base command.
@@ -27,7 +27,10 @@ public void run() {
2727
}
2828

2929
/**
30-
* Return execution code (CLI)
30+
* Return execution code (CLI).
31+
*
32+
* @return
33+
* returned code by the command
3134
*/
3235
public abstract ExitCode execute();
3336

astra-shell/src/main/java/com/datastax/astra/shell/cmd/ExitCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.datastax.astra.shell.cmd;
22

33
import com.datastax.astra.shell.ExitCode;
4-
import com.datastax.astra.shell.utils.ShellPrinter;
4+
import com.datastax.astra.shell.out.ShellPrinter;
55
import com.github.rvesse.airline.annotations.Command;
66

77
/**

astra-shell/src/main/java/com/datastax/astra/shell/cmd/HelpCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @author Cedrick LUNVEN (@clunven)
1010
*
1111
* @param <T>
12+
* generic for the Help Command
1213
*/
1314
@Command(name = "help", description = "View help for any command")
1415
public class HelpCommand<T> extends Help<T> {

astra-shell/src/main/java/com/datastax/astra/shell/cmd/QuitCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.datastax.astra.shell.cmd;
22

33
import com.datastax.astra.shell.ExitCode;
4-
import com.datastax.astra.shell.utils.LoggerShell;
4+
import com.datastax.astra.shell.out.LoggerShell;
55
import com.github.rvesse.airline.annotations.Command;
66

77
/**

astra-shell/src/main/java/com/datastax/astra/shell/cmd/config/ConfigCreate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.datastax.astra.sdk.organizations.OrganizationsClient;
77
import com.datastax.astra.sdk.organizations.domain.Organization;
88
import com.datastax.astra.shell.ExitCode;
9-
import com.datastax.astra.shell.utils.ShellPrinter;
9+
import com.datastax.astra.shell.out.ShellPrinter;
1010
import com.github.rvesse.airline.annotations.Arguments;
1111
import com.github.rvesse.airline.annotations.Command;
1212
import com.github.rvesse.airline.annotations.Option;

0 commit comments

Comments
 (0)