epugh commented on code in PR #5337:
URL: https://github.com/apache/solr/pull/5337#discussion_r4647034436


##########
solr/core/src/java/org/apache/solr/cli/PackageTool.java:
##########
@@ -59,7 +59,8 @@
     exitCodeListHeading = "%nExit Codes:%n",
     exitCodeList = {
       "0:Operation completed successfully.",
-      "1:Operation failed; check output for details."
+      "1:Operation failed; check output for details.",
+      "2:Invalid or incomplete command."

Review Comment:
   cool!



##########
solr/core/src/java/org/apache/solr/cli/SolrCLI.java:
##########
@@ -230,9 +230,29 @@ public static int parseWithCommonsCli(String[] args) 
throws Exception {
         args == null || args.length == 0 || args[0] == null || 
args[0].trim().isEmpty();
     final boolean isHelpCommand = !hasNoCommand && Arrays.asList("-h", 
"--help").contains(args[0]);
 
-    if (hasNoCommand || isHelpCommand) {
+    if (isHelpCommand) {
       printHelp();
-      runtime.exit(1);
+      runtime.exit(0);
+    }
+    if (hasNoCommand) {
+      printHelp();
+      runtime.exit(2);
+    }
+
+    boolean missingSubcommand = false;
+
+    if (args.length == 1 && "package".equals(args[0])) {
+      printToolHelp(new PackageTool(runtime));
+      return 2;
+    }
+    if ("snapshot".equals(args[0])

Review Comment:
   ugh...    Why does snapshot not work the same as ZK or package?   



##########
solr/core/src/java/org/apache/solr/cli/SolrCLI.java:
##########
@@ -151,9 +152,8 @@ public static void main(String[] args) throws Exception {
   }
 
   /**
-   * The {@code bin/solr} script invokes the tool with a single empty argument 
when it wants the
-   * top-level help (see the {@code --help} handling in {@code bin/solr}). 
picocli would treat that
-   * empty string as an unknown subcommand, so drop it.
+   * Drops a leading empty argument. Kept for back-compat with older {@code 
bin/solr} scripts that

Review Comment:
   do we need this?    don't the bin/solr scripts evolve hand in hand with 
SolrCLI?



##########
solr/core/src/java/org/apache/solr/cli/SolrCLI.java:
##########
@@ -230,9 +230,29 @@ public static int parseWithCommonsCli(String[] args) 
throws Exception {
         args == null || args.length == 0 || args[0] == null || 
args[0].trim().isEmpty();
     final boolean isHelpCommand = !hasNoCommand && Arrays.asList("-h", 
"--help").contains(args[0]);
 
-    if (hasNoCommand || isHelpCommand) {
+    if (isHelpCommand) {
       printHelp();
-      runtime.exit(1);
+      runtime.exit(0);
+    }
+    if (hasNoCommand) {
+      printHelp();
+      runtime.exit(2);
+    }
+
+    boolean missingSubcommand = false;
+
+    if (args.length == 1 && "package".equals(args[0])) {
+      printToolHelp(new PackageTool(runtime));
+      return 2;
+    }
+    if ("snapshot".equals(args[0])
+        && (args.length == 1
+            || (args.length == 2 && Arrays.asList("-h", 
"--help").contains(args[1])))) {
+      print(
+          "Snapshot commands: snapshot-create, snapshot-list, 
snapshot-describe, "

Review Comment:
   i see...   we don't have `bin/solr snapshot create`...  ;-(.  But we do have 
that pattern for zk and package.  We should fix that!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to