Skip to content

Commit

Permalink
Allows to create a project that don't include any features
Browse files Browse the repository at this point in the history
Closes gh-770
  • Loading branch information
rainboyan committed Dec 2, 2024
1 parent 61f5a76 commit e109208
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
boolean inPlace = commandLine.hasOption('inplace') || GrailsCli.isInteractiveModeActive()
String appName = commandLine.remainingArgs ? commandLine.remainingArgs[0] : ''

List<String> features = commandLine.optionValue('features')?.toString()?.split(',')?.toList()
List<String> features = commandLine.hasOption('features') ?
((commandLine.optionValue('features') && !(commandLine.optionValue('features') instanceof Boolean)) ?
commandLine.optionValue('features').toString()?.split(',')?.toList() : []) : null
Map<String, String> args = getCommandArguments(commandLine)

CreateAppCommandObject cmd = new CreateAppCommandObject(
Expand Down Expand Up @@ -356,9 +358,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
console.println(" Name:".padRight(20) + appName)
console.println(" Package:".padRight(20) + defaultPackageName)
console.println(" Profile:".padRight(20) + profileName)
if (features) {
console.println(" Features:".padRight(20) + features*.name?.join(', '))
}
console.println(" Features:".padRight(20) + features*.name?.join(', '))
if (cmd.template) {
console.println(" Template:".padRight(20) + cmd.template)
}
Expand Down Expand Up @@ -415,7 +415,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos

protected List<Feature> evaluateFeatures(Profile profile, List<String> requestedFeatures, GrailsConsole console) {
List<Feature> features
if (requestedFeatures) {
if (requestedFeatures != null && requestedFeatures.size() > 0) {
List<String> allFeatureNames = profile.features*.name
Collection<String> validFeatureNames = requestedFeatures.intersect(allFeatureNames)
requestedFeatures.removeAll(allFeatureNames)
Expand All @@ -432,6 +432,9 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
}
features = (profile.features.findAll { Feature f -> validFeatureNames.contains(f.name) } + profile.requiredFeatures).unique()
}
else if (requestedFeatures != null && requestedFeatures.size() == 0) {
features = Collections.emptyList()
}
else {
features = (profile.defaultFeatures + profile.requiredFeatures).toList().unique()
}
Expand Down

0 comments on commit e109208

Please sign in to comment.