Skip to content

Commit def66cc

Browse files
committed
Add warning to console if a flag is supplied that isn't handled
1 parent 862c2bc commit def66cc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
210210
def mainCommandLine = executionContext.commandLine
211211
def profileName = evaluateProfileName(mainCommandLine)
212212

213+
List<String> validFlags = [INPLACE_FLAG, PROFILE_FLAG, FEATURES_FLAG]
214+
mainCommandLine.undeclaredOptions.each { String key, Object value ->
215+
if (!validFlags.contains(key)) {
216+
List possibleSolutions = validFlags.findAll { it.substring(0, 2) == key.substring(0, 2) }
217+
StringBuilder warning = new StringBuilder("Unrecognized flag: ${key}.")
218+
if (possibleSolutions) {
219+
warning.append(" Possible solutions: ")
220+
warning.append(possibleSolutions.join(", "))
221+
}
222+
GrailsConsole.instance.warn(warning.toString())
223+
}
224+
}
225+
213226
Profile profileInstance = profileRepository.getProfile(profileName)
214227
if( !validateProfile(profileInstance, profileName, executionContext)) {
215228
return false

0 commit comments

Comments
 (0)