Skip to content

Commit 06b5662

Browse files
committed
Refine CLI parameters and output
1 parent 29552ce commit 06b5662

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

convex-cli/src/main/java/convex/cli/Main.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class Main extends ACommand {
7777
@Option(names = { "-k","--key" },
7878
defaultValue = "${env:CONVEX_KEY}",
7979
scope = ScopeType.INHERIT,
80-
description = "Keystore filename. Default: ${DEFAULT-VALUE}")
80+
description = "Public key to use. Default: ${DEFAULT-VALUE}")
8181
private String keySpec;
8282

8383
@Option(names = { "-p","--password" },
@@ -92,7 +92,10 @@ public class Main extends ACommand {
9292
description = "Apply strict security. Will forbid actions with dubious security implications.")
9393
private boolean paranoid;
9494

95-
@Option(names = {"--keystore-password" },
95+
/**
96+
* Password for keystore. Option named to match Java keytool
97+
*/
98+
@Option(names = {"--storepass" },
9699
scope = ScopeType.INHERIT,
97100
defaultValue = "${env:CONVEX_KEYSTORE_PASSWORD}",
98101
description = "Password to read/write to the Keystore")
@@ -112,7 +115,7 @@ public class Main extends ACommand {
112115
@Option(names = { "-v","--verbose" },
113116
scope = ScopeType.INHERIT,
114117
defaultValue = "${env:CONVEX_VERBOSE_LEVEL:-2}",
115-
description = "Specify verbosity level. Use -v0 to suppress user output. Default: ${DEFAULT-VALUE}")
118+
description = "Specify verbosity level. Use -v0 to suppress user output, -v5 for all log output. Default: ${DEFAULT-VALUE}")
116119
private Integer verbose;
117120

118121
public Main() {
@@ -173,7 +176,9 @@ public int mainExecute(String[] args) {
173176
if (verbose == null)
174177
verbose = 0;
175178
if (verbose >= 0 && verbose < verboseLevels.length) {
176-
// OK
179+
// Set root logger level?
180+
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
181+
root.setLevel(verboseLevels[verbose]);
177182
} else {
178183
commandLine.getErr().println("ERROR: Invalid verbosity level: " + verbose);
179184
return ExitCodes.ERROR;
@@ -560,6 +565,11 @@ public EtchStore getEtchStore(String etchStoreFilename) {
560565
}
561566
}
562567

568+
/**
569+
* Prompt the user for a Y/N answer
570+
* @param string
571+
* @return
572+
*/
563573
public boolean question(String string) {
564574
if (!isInteractive()) throw new CLIError("Can't ask user question in non-interactive mode: "+string);
565575
try {
@@ -573,6 +583,11 @@ public boolean question(String string) {
573583
return false;
574584
}
575585

586+
/**
587+
* Prompt the user for String input
588+
* @param string
589+
* @return
590+
*/
576591
public String prompt(String string) {
577592
if (!isInteractive()) throw new CLIError("Can't prompt for user input in non-interactive mode: "+string);
578593

convex-cli/src/test/java/convex/cli/key/KeyExportTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void testKeyGenerateAndExport() {
4141
// command key.generate
4242
CLTester tester = CLTester.run(
4343
"key", "generate",
44-
"--keystore-password", new String(KEYSTORE_PASSWORD),
44+
"--storepass", new String(KEYSTORE_PASSWORD),
4545
"--password", new String(KEY_PASSWORD),
4646
"--keystore", KEYSTORE_FILENAME
4747
);
@@ -62,7 +62,7 @@ public void testKeyGenerateAndExport() {
6262
tester = CLTester.run(
6363
"key",
6464
"export",
65-
"--keystore-password", new String(KEYSTORE_PASSWORD),
65+
"--storepass", new String(KEYSTORE_PASSWORD),
6666
"--password", new String(KEY_PASSWORD),
6767
"--keystore", KEYSTORE_FILENAME,
6868
"--public-key", publicKey,
@@ -79,7 +79,7 @@ public void testKeyGenerateAndExport() {
7979
"key",
8080
"export",
8181
"seed",
82-
"--keystore-password", new String(KEYSTORE_PASSWORD),
82+
"--storepass", new String(KEYSTORE_PASSWORD),
8383
"--password", new String(KEY_PASSWORD),
8484
"--keystore", KEYSTORE_FILENAME,
8585
"--public-key", publicKey

convex-cli/src/test/java/convex/cli/key/KeyImportTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void testKeyImportPEM() {
4141
"import",
4242
"pem",
4343
"-n",
44-
"--keystore-password", new String(KEYSTORE_PASSWORD),
44+
"--storepass", new String(KEYSTORE_PASSWORD),
4545
"--keystore", KEYSTORE_FILENAME,
4646
"--text", pemText,
4747
"--import-password", new String(IMPORT_PASSWORD)
@@ -51,7 +51,7 @@ public void testKeyImportPEM() {
5151
CLTester t2=CLTester.run(
5252
"key" ,
5353
"list",
54-
"--keystore-password", new String(KEYSTORE_PASSWORD),
54+
"--storepass", new String(KEYSTORE_PASSWORD),
5555
"--keystore", KEYSTORE_FILENAME);
5656

5757
assertEquals(ExitCodes.SUCCESS,t2.getResult());
@@ -67,7 +67,7 @@ public void testKeyImportSeed() {
6767
"key",
6868
"import",
6969
"seed",
70-
"--keystore-password", new String(KEYSTORE_PASSWORD),
70+
"--storepass", new String(KEYSTORE_PASSWORD),
7171
"--keystore", KEYSTORE_FILENAME,
7272
"--text", keyPair.getSeed().toString(),
7373
"--password", KEY_PASSWORD,
@@ -81,7 +81,7 @@ public void testKeyImportSeed() {
8181
"key" ,
8282
"list",
8383
"--password",KEY_PASSWORD,
84-
"--keystore-password", new String(KEYSTORE_PASSWORD),
84+
"--storepass", new String(KEYSTORE_PASSWORD),
8585
"--keystore", KEYSTORE_FILENAME);
8686

8787
assertEquals(ExitCodes.SUCCESS,t2.getResult());
@@ -99,7 +99,7 @@ public void testKeyImportBIP39() {
9999
"key",
100100
"import",
101101
"bip39",
102-
"--keystore-password", new String(KEYSTORE_PASSWORD),
102+
"--storepass", new String(KEYSTORE_PASSWORD),
103103
"--keystore", KEYSTORE_FILENAME,
104104
"--password",KEY_PASSWORD,
105105
"--text", "elder mail trick garage hour enjoy attack fringe problem motion poem security caught false penalty",
@@ -113,7 +113,7 @@ public void testKeyImportBIP39() {
113113
"key" ,
114114
"list",
115115
"--password",KEY_PASSWORD,
116-
"--keystore-password", new String(KEYSTORE_PASSWORD),
116+
"--storepass", new String(KEYSTORE_PASSWORD),
117117
"--keystore", KEYSTORE_FILENAME);
118118

119119
assertEquals(ExitCodes.SUCCESS,t2.getResult());

convex-cli/src/test/java/convex/cli/key/KeyTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void testKeyGenerateAndUse() throws IOException {
3939
"key",
4040
"generate",
4141
"-p", KEY_PASSWORD,
42-
"--keystore-password", KEYSTORE_PASSWORD,
42+
"--storepass", KEYSTORE_PASSWORD,
4343
"--keystore", fileName);
4444
tester.assertResult(0);
4545
String key = tester.getOutput().trim();
@@ -50,11 +50,11 @@ public void testKeyGenerateAndUse() throws IOException {
5050
assertTrue(fp.exists());
5151

5252
// command key.list
53-
tester = CLTester.run("key", "list", "--keystore-password", KEYSTORE_PASSWORD, "--keystore", fileName);
53+
tester = CLTester.run("key", "list", "--storepass", KEYSTORE_PASSWORD, "--keystore", fileName);
5454
//tester.assertOutputMatch("^Index Public Key\\s+1");
5555

5656
// command key.list with non-existant keystore
57-
tester = CLTester.run("key", "list", "--keystore-password", KEYSTORE_PASSWORD, "--keystore","bad-keystore.pfx");
57+
tester = CLTester.run("key", "list", "--storepass", KEYSTORE_PASSWORD, "--keystore","bad-keystore.pfx");
5858
assertNotEquals(ExitCodes.SUCCESS,tester.getResult());
5959

6060
}

0 commit comments

Comments
 (0)