Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix for GRAILS-9035. 'grails -help' and 'grails -help foo' now shows …

…a deprecation message with instructions to use 'grails help' or 'grails help foo'.

'grails help' now shows the list of options as 'grails -help' previously did, in addition to the list of targets.
  • Loading branch information...
commit f8d6b99e5eb0353071edd688d4a1c26fbb0fe8f1 1 parent 0f2c77b
Ronny Løvtangen authored April 22, 2012
7  grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/GrailsScriptRunner.java
@@ -184,7 +184,11 @@ public static void main(String[] args) {
184 184
         }
185 185
 
186 186
         if (commandLine.hasOption(CommandLine.HELP_ARGUMENT)) {
187  
-            console.log(parser.getHelpMessage());
  187
+            if (commandLine.getCommandName() != null) {
  188
+                console.log("The '-help' option is deprecated; use 'grails help [target]'");
  189
+            } else {
  190
+                console.log("The '-help' option is deprecated; use 'grails help'");
  191
+            }
188 192
             System.exit(0);
189 193
         }
190 194
 
@@ -247,7 +251,6 @@ public static CommandLineParser getCommandLineParser() {
247 251
         parser.addOption(CommandLine.STACKTRACE_ARGUMENT, "Enable stack traces in output");
248 252
         parser.addOption(CommandLine.AGENT_ARGUMENT, "Enable the reloading agent");
249 253
         parser.addOption(CommandLine.NON_INTERACTIVE_ARGUMENT, "Whether to allow the command line to request input");
250  
-        parser.addOption(CommandLine.HELP_ARGUMENT, "Command line help");
251 254
         parser.addOption(CommandLine.VERSION_ARGUMENT, "Current Grails version");
252 255
         parser.addOption(CommandLine.NOANSI_ARGUMENT, "Disables ANSI output");
253 256
         return parser;
4  grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLineParser.java
@@ -142,9 +142,9 @@ private void parseInternal(DefaultCommandLine cl, String[] args, boolean firstAr
142 142
         }
143 143
     }
144 144
 
145  
-    public String getHelpMessage() {
  145
+    public String getOptionsHelpMessage() {
146 146
         String ls = System.getProperty("line.separator");
147  
-        usageMessage = "usage: grails [options] [command]";
  147
+        usageMessage = "Available options:";
148 148
         StringBuilder sb = new StringBuilder(usageMessage);
149 149
         sb.append(ls);
150 150
         for (Option option : declaredOptions.values()) {
2  grails-bootstrap/src/test/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLineParserSpec.groovy
@@ -151,7 +151,7 @@ class CommandLineParserSpec extends Specification {
151 151
 
152 152
         then:
153 153
             String ls = System.getProperty("line.separator");
154  
-            parser.helpMessage == "usage: grails [options] [command]${ls} -interactive-mode        Enabled interactive mode${ls} -version                 Shows the vesrion${ls}"
  154
+            parser.optionsHelpMessage == "Available options:${ls} -interactive-mode        Enabled interactive mode${ls} -version                 Shows the vesrion${ls}"
155 155
     }
156 156
 
157 157
     // STRING tests
6  scripts/Help_.groovy
@@ -24,6 +24,7 @@
24 24
 
25 25
 import grails.util.GrailsNameUtils
26 26
 import grails.util.Environment
  27
+import org.codehaus.groovy.grails.cli.GrailsScriptRunner
27 28
 
28 29
 includeTargets << grailsScript("_GrailsInit")
29 30
 
@@ -76,12 +77,15 @@ target ('default' : "Prints out the help for each script") {
76 77
     else {
77 78
         println """
78 79
 Usage (optionals marked with *):
79  
-grails [environment]* [target] [arguments]*
  80
+grails [environment]* [options]* [target] [arguments]*
80 81
 
81 82
 Examples:
82 83
 grails dev run-app
83 84
 grails create-app books
84 85
 
  86
+"""
  87
+        println GrailsScriptRunner.commandLineParser.optionsHelpMessage
  88
+        println """
85 89
 Available Targets (type grails help 'target-name' for more info):"""
86 90
 
87 91
         scripts.unique { it.name }. sort{ it.name }.each { file ->

0 notes on commit f8d6b99

Please sign in to comment.
Something went wrong with that request. Please try again.