Skip to content

Commit de63aeb

Browse files
committed
Command profile-info should only show the Profile's internal commands and features
Closes gh-1040
1 parent 3f98c9d commit de63aeb

3 files changed

Lines changed: 29 additions & 39 deletions

File tree

grace-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -276,6 +276,13 @@ abstract class AbstractProfile implements Profile {
276276
calculatedFeatures
277277
}
278278

279+
@Override
280+
Iterable<Feature> getInternalFeatures() {
281+
Set<Feature> calculatedFeatures = []
282+
calculatedFeatures.addAll(features)
283+
calculatedFeatures
284+
}
285+
279286
@Override
280287
List<String> getBuildMergeProfileNames() {
281288
if (buildMerge != null) {
@@ -423,6 +430,11 @@ abstract class AbstractProfile implements Profile {
423430
commandsByName[name]
424431
}
425432

433+
@Override
434+
List<Command> getInternalCommands() {
435+
this.internalCommands
436+
}
437+
426438
@Override
427439
Iterable<Command> getCommands(ProjectContext context) {
428440
if (commandsByName == null) {

grace-shell/src/main/groovy/org/grails/cli/profile/Profile.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
*
3232
* @author Graeme Rocher
3333
* @author Lari Hotari
34+
* @author Michael Yan
3435
*
3536
* @since 3.0
3637
*/
@@ -71,6 +72,11 @@ public interface Profile {
7172
*/
7273
Iterable<Feature> getFeatures();
7374

75+
/**
76+
* @return The internal features for this profile
77+
*/
78+
Iterable<Feature> getInternalFeatures();
79+
7480
/**
7581
* @return The default features for this profile
7682
*/
@@ -123,6 +129,13 @@ public interface Profile {
123129
*/
124130
Command getCommand(ProjectContext context, String name);
125131

132+
/**
133+
* The profile's internal {@link Command} instances
134+
*
135+
* @return A list of {@link Command} instances
136+
*/
137+
List<Command> getInternalCommands();
138+
126139
/**
127140
* The profile completers
128141
* @param context The {@link org.grails.cli.profile.ProjectContext} instance

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

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package org.grails.cli.profile.commands
1818
import groovy.transform.CompileStatic
1919

2020
import grails.build.logging.GrailsConsole
21-
import grails.config.ConfigMap
2221

2322
import org.grails.cli.profile.Command
2423
import org.grails.cli.profile.CommandDescription
@@ -29,8 +28,6 @@ import org.grails.cli.profile.Profile
2928
import org.grails.cli.profile.ProfileRepository
3029
import org.grails.cli.profile.ProfileRepositoryAware
3130
import org.grails.cli.profile.ProjectCommand
32-
import org.grails.cli.profile.ProjectContext
33-
import org.grails.config.CodeGenConfig
3431

3532
/**
3633
* A command to find out information about the given profile
@@ -79,7 +76,7 @@ class ProfileInfoCommand extends ArgumentCompletingCommand implements GlobalComm
7976
console.log('')
8077
console.log('Provided Commands:')
8178
console.log('-' * 80)
82-
Iterable<Command> commands = findCommands(profile, console).sort { Command c -> c.name }.toUnique { Command c -> c.name }
79+
Iterable<Command> commands = profile.internalCommands.sort { Command c -> c.name }
8380

8481
for (cmd in commands) {
8582
StringBuilder description = new StringBuilder()
@@ -90,7 +87,7 @@ class ProfileInfoCommand extends ArgumentCompletingCommand implements GlobalComm
9087
console.log('')
9188
console.log('Provided Features:')
9289
console.log('-' * 80)
93-
Iterable<Feature> features = profile.features.sort { Feature f -> f.name }
90+
Iterable<Feature> features = profile.internalFeatures.sort { Feature f -> f.name }
9491

9592
for (feature in features) {
9693
console.log("* ${feature.name.padRight(30)} ${feature.description}")
@@ -109,36 +106,4 @@ class ProfileInfoCommand extends ArgumentCompletingCommand implements GlobalComm
109106
}
110107
}
111108

112-
protected Iterable<Command> findCommands(Profile profile, GrailsConsole console) {
113-
Iterable<Command> commands = profile.getCommands(new ProjectContext() {
114-
115-
@Override
116-
GrailsConsole getConsole() {
117-
console
118-
}
119-
120-
@Override
121-
File getBaseDir() {
122-
new File('.')
123-
}
124-
125-
@Override
126-
ConfigMap getConfig() {
127-
new CodeGenConfig()
128-
}
129-
130-
@Override
131-
String navigateConfig(String... path) {
132-
config.navigate(path)
133-
}
134-
135-
@Override
136-
<T> T navigateConfigForType(Class<T> requiredType, String... path) {
137-
(T) config.navigate(path)
138-
}
139-
140-
})
141-
commands
142-
}
143-
144109
}

0 commit comments

Comments
 (0)