Commits

Anonymous committed cfbaa5e

Print riaksearch-admin usage when command has wrong number of parameters

This prevents function_clause errors being triggered in riak_kv_console
when the user incorrectly passes or omits a parameter.

  • Participants
  • Parent commits c468b29

Comments (0)

Files changed (1)

File rel/files/riaksearch-admin

 # Check the first argument for instructions
 case "$1" in
     join)
+        if [ $# -ne 2 ]; then
+            echo "Usage: $SCRIPT join <node>"
+            exit 1
+        fi
+
         # Make sure the local node IS running
         RES=`$NODETOOL ping`
         if [ "$RES" != "pong" ]; then
         ;;
 
     leave)
+        if [ $# -ne 1 ]; then
+            echo "Usage: $SCRIPT leave"
+            exit 1
+        fi
+
         # Make sure the local node is running
         RES=`$NODETOOL ping`
         if [ "$RES" != "pong" ]; then
         ;;
 
     status)
+        if [ $# -ne 1 ]; then
+            echo "Usage: $SCRIPT status"
+            exit 1
+        fi
+
         # Make sure the local node IS running
         RES=`$NODETOOL ping`
         if [ "$RES" != "pong" ]; then
         ;;
 
     ringready)
+        if [ $# -ne 1 ]; then
+            echo "Usage: $SCRIPT ringready"
+            exit 1
+        fi
+
         # Make sure the local node IS running
         RES=`$NODETOOL ping`
         if [ "$RES" != "pong" ]; then
         ;;
 
     transfers)
+        if [ $# -ne 1 ]; then
+            echo "Usage: $SCRIPT transfers"
+            exit 1
+        fi
+
         # Make sure the local node IS running
         RES=`$NODETOOL ping`
         if [ "$RES" != "pong" ]; then
             exit 1
         fi
 
-        $NODETOOL rpc riak_kv_js_manager reload
+        shift #optional names come after 'js_reload'
+        $NODETOOL rpc riak_kv_js_manager reload $@
         ;;
 
     reip)