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/08/03 18:15:57 UTC

[solr] branch main updated: SOLR-16822: fix -h meaning help and hostname for start and restart. (#1819)

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 6bcf1b7d7fe SOLR-16822: fix -h meaning help and hostname for start and restart. (#1819)
6bcf1b7d7fe is described below

commit 6bcf1b7d7fe145cebae7997cc0a7ab0f436a0e73
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Thu Aug 3 14:15:50 2023 -0400

    SOLR-16822: fix -h meaning help and hostname for start and restart. (#1819)
    
    Update the bin/solr start and restart commands "-h" parameter from being short hand for "-host" to instead meaning "return help", to follow the pattern of the other Solr CLI commands.
---
 solr/CHANGES.txt                                                  | 2 ++
 solr/bin/solr                                                     | 6 +++---
 solr/bin/solr.cmd                                                 | 4 ++--
 solr/packaging/test/test_help.bats                                | 8 ++++++++
 .../deployment-guide/pages/solr-control-script-reference.adoc     | 4 ++--
 5 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d2fd1e5556e..0745371a5ea 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -57,6 +57,8 @@ Other Changes
 
 * SOLR-16892: bin/solr create command supports both standalone and cloud modes, and deprecate create_core and create_collection commands.   (Eric Pugh)
 
+* SOLR-16822: Change meaning of -h from shorhand for -host to instead return help information for bin/solr start and restart commands. (Eric Pugh)
+
 ==================  9.4.0 ==================
 New Features
 ---------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index e78693bba29..1a91582678d 100644
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -350,7 +350,7 @@ function print_usage() {
     echo "                          solr.in.sh, an embedded ZooKeeper instance is started on Solr port+1000,"
     echo "                          such as 9983 if Solr is bound to 8983"
     echo ""
-    echo "  -h/-host <host>       Specify the hostname for this Solr instance"
+    echo "  -host <host>          Specify the hostname for this Solr instance"
     echo ""
     echo "  -p <port>             Specify the port to start the Solr HTTP listener on; default is 8983"
     echo "                          The specified port (SOLR_PORT) will also be used to determine the stop port"
@@ -1270,13 +1270,13 @@ if [ $# -gt 0 ]; then
             FG="true"
             shift
         ;;
-        -h|-host)
+        -host)
             if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Hostname is required when using the $1 option!"
               exit 1
             fi
             SOLR_HOST="$2"
-            PASS_TO_RUN_EXAMPLE+=("-h" "$SOLR_HOST")
+            PASS_TO_RUN_EXAMPLE+=("-host" "$SOLR_HOST")
             shift 2
         ;;
         -m|-memory)
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index f133a45d471..71e3ab42bee 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -292,7 +292,7 @@ goto done
 @echo                   solr.in.cmd, an embedded ZooKeeper instance is started on Solr port+1000,
 @echo                   such as 9983 if Solr is bound to 8983
 @echo.
-@echo   -h host       Specify the hostname for this Solr instance
+@echo   -host host    Specify the hostname for this Solr instance
 @echo.
 @echo   -p port       Specify the port to start the Solr HTTP listener on; default is 8983
 @echo                   The specified port (SOLR_PORT) will also be used to determine the stop port
@@ -503,6 +503,7 @@ set "firstTwo=%arg:~0,2%"
 IF "%SCRIPT_CMD%"=="" set SCRIPT_CMD=start
 IF [%1]==[] goto process_script_cmd
 IF "%1"=="-help" goto usage
+IF "%1"=="-h" goto usage
 IF "%1"=="-usage" goto usage
 IF "%1"=="/?" goto usage
 IF "%1"=="-f" goto set_foreground_mode
@@ -520,7 +521,6 @@ IF "%1"=="-t" goto set_solr_data_dir
 IF "%1"=="-solr.home" goto set_solr_home_dir
 IF "%1"=="-e" goto set_example
 IF "%1"=="-example" goto set_example
-IF "%1"=="-h" goto set_host
 IF "%1"=="-host" goto set_host
 IF "%1"=="-m" goto set_memory
 IF "%1"=="-memory" goto set_memory
diff --git a/solr/packaging/test/test_help.bats b/solr/packaging/test/test_help.bats
index c2fb863cd46..a6a8a497b36 100644
--- a/solr/packaging/test/test_help.bats
+++ b/solr/packaging/test/test_help.bats
@@ -38,6 +38,14 @@ setup() {
   refute_output --partial 'ERROR'
 }
 
+@test "start h flag prints help" {
+  run solr start -h
+  assert_output --partial 'Usage: solr start'
+  refute_output --partial 'ERROR: Hostname is required when using the -h option!'
+}
+
+
+
 @test "stop help flag prints help" {
   run solr stop -help
   assert_output --partial 'Usage: solr stop'
diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
index 80eaebf4cef..12e1a4ea0f6 100644
--- a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc
@@ -142,7 +142,7 @@ You cannot use this option when running examples with the `-e` option.
 +
 *Example*: `bin/solr start -f`
 
-`-host <hostname>` or `-h <hostname>`::
+`-host <hostname>`::
 +
 [%autowidth,frame=none]
 |===
@@ -152,7 +152,7 @@ You cannot use this option when running examples with the `-e` option.
 Specify the hostname for this Solr instance.
 If this is not specified, `localhost` is assumed.
 +
-*Example*: `bin/solr start -h search.mysolr.com`
+*Example*: `bin/solr start -host search.mysolr.com`
 
 `-m <memory>`::
 +