You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ep...@apache.org on 2023/07/22 16:48:23 UTC
[solr] branch main updated: SOLR-16870: remove now dead lines of code (#1759)
This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 58f1761b0d1 SOLR-16870: remove now dead lines of code (#1759)
58f1761b0d1 is described below
commit 58f1761b0d16577fbc7afcfc8cb33694478b324b
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Sat Jul 22 12:48:18 2023 -0400
SOLR-16870: remove now dead lines of code (#1759)
---------
Co-authored-by: Willdotwhite <wi...@gmail.com>
---
solr/bin/solr | 20 +---------
solr/bin/solr.cmd | 44 ++++++----------------
.../core/src/java/org/apache/solr/cli/SolrCLI.java | 7 +++-
3 files changed, 18 insertions(+), 53 deletions(-)
diff --git a/solr/bin/solr b/solr/bin/solr
index 45aa5a108b5..09053117057 100644
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -339,25 +339,7 @@ function print_usage() {
echo -e "\nERROR: $ERROR_MSG\n"
fi
- if [ -z "${CMD:-}" ]; then
- echo ""
- echo "Usage: solr COMMAND OPTIONS"
- echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package"
- echo ""
- echo " Standalone server example (start Solr running in the background on port 8984):"
- echo ""
- echo " ./solr start -p 8984"
- echo ""
- echo " SolrCloud example (start Solr running in SolrCloud mode using localhost:2181 to connect to Zookeeper, with 1g max heap size and remote Java debug options enabled):"
- echo ""
- echo " ./solr start -c -m 1g -z localhost:2181 -a \"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044\""
- echo ""
- echo " Omit '-z localhost:2181' from the above command if you have defined ZK_HOST in solr.in.sh."
- echo ""
- echo "Pass -help or -h after any COMMAND to see command-specific usage information,"
- echo " such as: ./solr start -help or ./solr stop -h"
- echo ""
- elif [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then
+ if [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then
echo ""
echo "Usage: solr $CMD [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-s solr.solr.home] [-t solr.data.home] [-a \"additional-options\"] [-V]"
echo ""
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index e38f3645f17..ae16c5dacb5 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -223,11 +223,11 @@ set FIRST_ARG=%1
IF [%1]==[] goto usage
-IF "%1"=="-help" goto usage
-IF "%1"=="-usage" goto usage
-IF "%1"=="-h" goto usage
-IF "%1"=="--help" goto usage
-IF "%1"=="/?" goto usage
+IF "%1"=="-help" goto run_solrcli
+IF "%1"=="-usage" goto run_solrcli
+IF "%1"=="-h" goto run_solrcli
+IF "%1"=="--help" goto run_solrcli
+IF "%1"=="/?" goto run_solrcli
IF "%1"=="status" goto get_status
IF "%1"=="version" goto run_solrcli
IF "%1"=="-v" goto run_solrcli
@@ -264,12 +264,12 @@ goto parse_args
:usage
IF NOT "%SCRIPT_ERROR%"=="" ECHO %SCRIPT_ERROR%
-IF [%FIRST_ARG%]==[] goto script_usage
-IF "%FIRST_ARG%"=="-help" goto script_usage
-IF "%FIRST_ARG%"=="-usage" goto script_usage
-IF "%FIRST_ARG%"=="-h" goto script_usage
-IF "%FIRST_ARG%"=="--help" goto script_usage
-IF "%FIRST_ARG%"=="/?" goto script_usage
+IF [%FIRST_ARG%]==[] goto run_solrcli
+IF "%FIRST_ARG%"=="-help" goto run_solrcli
+IF "%FIRST_ARG%"=="-usage" goto run_solrcli
+IF "%FIRST_ARG%"=="-h" goto run_solrcli
+IF "%FIRST_ARG%"=="--help" goto run_solrcli
+IF "%FIRST_ARG%"=="/?" goto run_solrcli
IF "%SCRIPT_CMD%"=="start" goto start_usage
IF "%SCRIPT_CMD%"=="restart" goto start_usage
IF "%SCRIPT_CMD%"=="stop" goto stop_usage
@@ -283,26 +283,6 @@ IF "%SCRIPT_CMD%"=="auth" goto auth_usage
IF "%SCRIPT_CMD%"=="status" goto run_solrcli
goto done
-:script_usage
-@echo.
-@echo Usage: solr COMMAND OPTIONS
-@echo where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package
-@echo.
-@echo Standalone server example (start Solr running in the background on port 8984):
-@echo.
-@echo solr start -p 8984
-@echo.
-@echo SolrCloud example (start Solr running in SolrCloud mode using localhost:2181 to connect to Zookeeper, with 1g max heap size and remote Java debug options enabled):
-@echo.
-@echo solr start -c -m 1g -z localhost:2181 -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044"
-@echo.
-@echo Omit '-z localhost:2181' from the above command if you have defined ZK_HOST in solr.in.cmd.
-@echo.
-@echo Pass -help after any COMMAND to see command-specific usage information,
-@echo such as: solr start -help or solr stop -help
-@echo.
-goto done
-
:start_usage
@echo.
@echo Usage: solr %SCRIPT_CMD% [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-s solr.solr.home] [-t solr.data.home] [-a "additional-options"] [-V]
@@ -1665,8 +1645,6 @@ IF "%FIRST_ARG%"=="start" (
goto auth_usage
) ELSE IF "%FIRST_ARG%"=="status" (
goto run_solrcli
-) ELSE (
- goto script_usage
)
:need_java_home
diff --git a/solr/core/src/java/org/apache/solr/cli/SolrCLI.java b/solr/core/src/java/org/apache/solr/cli/SolrCLI.java
index 28de99ce25b..c7eff7622d1 100755
--- a/solr/core/src/java/org/apache/solr/cli/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/cli/SolrCLI.java
@@ -120,7 +120,12 @@ public class SolrCLI implements CLIO {
/** Runs a tool. */
public static void main(String[] args) throws Exception {
- if (args == null || args.length == 0 || args[0] == null || args[0].trim().length() == 0) {
+ final boolean hasNoCommand =
+ args == null || args.length == 0 || args[0] == null || args[0].trim().length() == 0;
+ final boolean isHelpCommand =
+ !hasNoCommand && Arrays.asList("-h", "--help", "/?").contains(args[0]);
+
+ if (hasNoCommand || isHelpCommand) {
printHelp();
exit(1);
}