Skip to content

Commit

Permalink
chore: Minor cleanup, plus bring back the module file Git thought was…
Browse files Browse the repository at this point in the history
… being deleted rather than replaced
  • Loading branch information
Cervator committed Jul 11, 2020
1 parent 05ca0f8 commit d21e82a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/groovy/BaseCommand.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ import picocli.CommandLine.Command
commandListHeading = "%n@|green Commands:|@%n%n")
class BaseCommand {

}
}
3 changes: 2 additions & 1 deletion config/groovy/Get.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import picocli.CommandLine.ParentCommand
import picocli.CommandLine.Command
import picocli.CommandLine.Mixin // Actually in use, annotation below may show syntax error due to Groovy's annotation by the same name. Works fine
// Actually in use, annotation below may show syntax error due to Groovy's annotation by the same name. Works fine
import picocli.CommandLine.Mixin
import picocli.CommandLine.Parameters

/**
Expand Down
3 changes: 3 additions & 0 deletions config/groovy/GooeyCLI.groovy
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

// Grab the Groovy extensions for PicoCLI - in IntelliJ Alt-ENTER on a `@Grab` to register contents for syntax highlighting
@Grab('info.picocli:picocli-groovy:4.3.2')
// TODO: Actually exists inside the Gradle Wrapper - gradle-6.4.1\lib\groovy-all-1.3-2.5.10.jar\groovyjarjarpicocli\
Expand Down
3 changes: 2 additions & 1 deletion config/groovy/Init.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import picocli.CommandLine.Command
import picocli.CommandLine.Help.Ansi
import picocli.CommandLine.Mixin // Is in use, IDE may think the Groovy-supplied is in use below and mark this unused
// Is in use, IDE may think the Groovy-supplied is in use below and mark this unused
import picocli.CommandLine.Mixin
import picocli.CommandLine.Parameters

@Command(name = "init", description = "Initializes a workspace with some useful things")
Expand Down
2 changes: 1 addition & 1 deletion config/groovy/ItemCommand.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ abstract class ItemCommand extends BaseCommand {
* @return the instantiated item type manager class
*/
abstract ManagedItem getManager(String optionGitOrigin)
}
}
28 changes: 28 additions & 0 deletions config/groovy/Module.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

import picocli.CommandLine.Command
import picocli.CommandLine.HelpCommand

// If using local groovy files the subcommands section may highlight as bad syntax in IntelliJ - that's OK
@Command(name = "module",
synopsisSubcommandLabel = "COMMAND", // Default is [COMMAND] indicating optional, but sub command here is required
subcommands = [
HelpCommand.class, // Adds standard help options (help as a subcommand, -h, and --help)
Recurse.class,
Update.class,
Get.class], // Note that these Groovy classes *must* start with a capital letter for some reason
description = "Sub command for interacting with modules")
class Module extends ItemCommand {
@Override
ManagedItem getManager(String optionGitOrigin) {
return new ManagedModule(optionGitOrigin)
}

// This is an example of a subcommand via method - used here so we can directly hit ManagedModule for something module-specific
// If in an external Refresh.groovy it _could_ specify ManagedModule, but it then could be added later to a non-module and break
@Command(name = "refresh", description = "Refreshes all build.gradle files in module directories")
void refresh() {
new ManagedModule().refreshGradle()
}
}

0 comments on commit d21e82a

Please sign in to comment.