@@ -54,6 +54,14 @@ import (
54
54
"github.com/gruntwork-io/terragrunt/pkg/log/format/placeholders"
55
55
)
56
56
57
+ // Command category names.
58
+ const (
59
+ MainCommandsCategoryName = "Main commands"
60
+ CatalogCommandsCategoryName = "Catalog commands"
61
+ ConfigurationCommandsCategoryName = "Configuration commands"
62
+ ShortcutsCommandsCategoryName = "OpenTofu shortcuts"
63
+ )
64
+
57
65
func init () {
58
66
cli .AppVersionTemplate = AppVersionTemplate
59
67
cli .AppHelpTemplate = AppHelpTemplate
@@ -69,7 +77,7 @@ type App struct {
69
77
func NewApp (opts * options.TerragruntOptions ) * App {
70
78
app := cli .NewApp ()
71
79
app .Name = "terragrunt"
72
- app .Usage = "Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale. For documentation, see https://terragrunt.gruntwork.io/."
80
+ app .Usage = "Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.\n For documentation, see https://terragrunt.gruntwork.io/."
73
81
app .Author = "Gruntwork <www.gruntwork.io>"
74
82
app .Version = version .GetVersion ()
75
83
app .Writer = opts .Writer
@@ -142,7 +150,7 @@ func (app *App) RunContext(ctx context.Context, args []string) error {
142
150
return nil
143
151
}
144
152
145
- // GlobalFlags returns global flags. For backward compatibility, the slice contains flags that have been moved to other commands and are hidden from the CLI help,
153
+ // GlobalFlags returns global flags. For backward compatibility, the slice contains flags that have been moved to other commands and are hidden from the CLI help.
146
154
func GlobalFlags (opts * options.TerragruntOptions ) cli.Flags {
147
155
globalFlags := global .NewFlags (opts , nil )
148
156
@@ -158,17 +166,17 @@ func GlobalFlags(opts *options.TerragruntOptions) cli.Flags {
158
166
graph .NewCommand (opts ), // graph
159
167
}
160
168
161
- var knownFlags []string
169
+ var seen []string
162
170
163
171
for _ , cmd := range commands {
164
172
for _ , flag := range cmd .Flags {
165
173
flagName := util .FirstElement (util .RemoveEmptyElements (flag .Names ()))
166
174
167
- if slices .Contains (knownFlags , flagName ) {
175
+ if slices .Contains (seen , flagName ) {
168
176
continue
169
177
}
170
178
171
- knownFlags = append (knownFlags , flagName )
179
+ seen = append (seen , flagName )
172
180
globalFlags = append (globalFlags , flags .NewMovedFlag (flag , cmd .Name , flags .StrictControlsByMovedGlobalFlags (opts .StrictControls , cmd .Name )))
173
181
}
174
182
}
@@ -202,30 +210,62 @@ func removeNoColorFlagDuplicates(args []string) []string {
202
210
203
211
// TerragruntCommands returns the set of Terragrunt commands.
204
212
func TerragruntCommands (opts * options.TerragruntOptions ) cli.Commands {
205
- cmds := cli.Commands {
206
- runCmd .NewCommand (opts ), // run
207
- runall .NewCommand (opts ), // runAction-all
208
- terragruntinfo .NewCommand (opts ), // terragrunt-info
209
- validateinputs .NewCommand (opts ), // validate-inputs
213
+ mainCommands := cli.Commands {
214
+ runall .NewCommand (opts ), // run-all
215
+ runCmd .NewCommand (opts ), // run
216
+ stack .NewCommand (opts ), // stack
217
+ graph .NewCommand (opts ), // graph
218
+ execCmd .NewCommand (opts ), // exec
219
+ }.SetCategory (
220
+ & cli.Category {
221
+ Name : MainCommandsCategoryName ,
222
+ Order : 10 , //nolint: mnd
223
+ },
224
+ )
225
+
226
+ catalogCommands := cli.Commands {
227
+ catalog .NewCommand (opts ), // catalog
228
+ scaffold .NewCommand (opts ), // scaffold
229
+ }.SetCategory (
230
+ & cli.Category {
231
+ Name : CatalogCommandsCategoryName ,
232
+ Order : 20 , //nolint: mnd
233
+ },
234
+ )
235
+
236
+ configurationCommands := cli.Commands {
210
237
graphdependencies .NewCommand (opts ), // graph-dependencies
211
- hclfmt .NewCommand (opts ), // hclfmt
212
- renderjson .NewCommand (opts ), // render-json
213
- awsproviderpatch .NewCommand (opts ), // aws-provider-patch
214
238
outputmodulegroups .NewCommand (opts ), // output-module-groups
215
- catalog .NewCommand (opts ), // catalog
216
- scaffold .NewCommand (opts ), // scaffold
217
- stack .NewCommand (opts ), // stack
218
- graph .NewCommand (opts ), // graph
239
+ validateinputs .NewCommand (opts ), // validate-inputs
219
240
hclvalidate .NewCommand (opts ), // hclvalidate
220
- execCmd .NewCommand (opts ), // exec
221
- helpCmd .NewCommand (opts ), // help
222
- versionCmd .NewCommand (opts ), // version
241
+ hclfmt .NewCommand (opts ), // hclfmt
223
242
info .NewCommand (opts ), // info
224
- }
225
- cmds = append (cmds , commands .NewShortcutsCommands (opts )... )
226
- cmds = append (cmds , commands .NewDeprecatedCommands (opts )... )
243
+ terragruntinfo .NewCommand (opts ), // terragrunt-info
244
+ renderjson .NewCommand (opts ), // render-json
245
+ helpCmd .NewCommand (opts ), // help (hidden)
246
+ versionCmd .NewCommand (opts ), // version (hidden)
247
+ awsproviderpatch .NewCommand (opts ), // aws-provider-patch (hidden)
248
+ }.SetCategory (
249
+ & cli.Category {
250
+ Name : ConfigurationCommandsCategoryName ,
251
+ Order : 30 , //nolint: mnd
252
+ },
253
+ )
254
+
255
+ shortcutsCommands := commands .NewShortcutsCommands (opts ).SetCategory (
256
+ & cli.Category {
257
+ Name : ShortcutsCommandsCategoryName ,
258
+ Order : 40 , //nolint: mnd
259
+ },
260
+ )
261
+
262
+ allCommands := mainCommands .
263
+ Merge (catalogCommands ... ).
264
+ Merge (configurationCommands ... ).
265
+ Merge (shortcutsCommands ... ).
266
+ Merge (commands .NewDeprecatedCommands (opts )... )
227
267
228
- return cmds
268
+ return allCommands
229
269
}
230
270
231
271
// WrapWithTelemetry wraps CLI command execution with setting of telemetry context and labels, if telemetry is disabled, just runAction the command.
0 commit comments