11package com.rundeck.plugin
22
3- import com.lexicalscope.jewel.cli.Option
43import com.rundeck.plugin.template.FilesystemArtifactTemplateGenerator
54import com.rundeck.plugin.template.PluginType
6- import org.rundeck.toolbelt.Command
7- import org.rundeck.toolbelt.CommandRunFailure
8- import org.rundeck.toolbelt.SubCommand
9- import org.rundeck.toolbelt.ToolBelt
10- import org.rundeck.toolbelt.input.jewelcli.JewelInput
5+ import com.rundeck.plugin.template.ServiceType
6+ import picocli.CommandLine
7+ import picocli.CommandLine.Option
8+ import picocli.CommandLine.Command
9+
10+
11+ import java.util.concurrent.Callable
1112
1213/*
1314 * Copyright 2018 Rundeck, Inc. (http://rundeck.com)
@@ -25,36 +26,36 @@ import org.rundeck.toolbelt.input.jewelcli.JewelInput
2526 * limitations under the License.
2627 */
2728
28- @SubCommand
29- class Generator {
29+ @Command (description = " Create a Rundeck plugin artifact." ,
30+ name = " plugin-bootstrap" , mixinStandardHelpOptions = true , version = " 1.1" )
31+ class Generator implements Callable<Void > {
3032
31- private static final List<String > VALID_PLUGIN_TYPES = [" java" ," script" ," ui" ]
32-
33- public static void main (String [] args ) throws IOException , CommandRunFailure {
34- ToolBelt . with(" plugin-bootstrap" , new JewelInput (), new Generator ()). runMain(args, true );
33+ static void main (String [] args ) throws Exception {
34+ try {
35+ CommandLine . call(new Generator (), args)
36+ }catch (Exception e){
37+ println (e. getMessage())
38+ }
3539 }
3640
37- @Command (description = " Create a Rundeck plugin artifact" )
38- public void create (CreateOpts createOpts ) {
39- if (! VALID_PLUGIN_TYPES . contains(createOpts. pluginType)) {
40- println " Artifact type must be one of: ${ VALID_PLUGIN_TYPES.join("|")} "
41- return
42- }
41+ @Option (names = [ " -n" , " --pluginName" ], description = " Plugin Name." , required = true )
42+ String pluginName;
43+ @Option (names = [ " -t" , " --pluginType" ] ,description = ' Plugin Type: ${COMPLETION-CANDIDATES}' , required = true )
44+ PluginType pluginType;
45+ @Option (names = [ " -s" , " --serviceType" ],description = ' Rundeck Service Type: ${COMPLETION-CANDIDATES}' , required = true )
46+ ServiceType serviceType
47+ @Option (names = [ " -d" , " --destinationDirectory" ],description = " The directory in which the artifact directory will be generated" , required = true )
48+ String destinationDirectory
49+
50+ @Override
51+ Void call () throws Exception {
4352 FilesystemArtifactTemplateGenerator generator = new FilesystemArtifactTemplateGenerator ()
44- println generator. generate(createOpts. pluginName,
45- PluginType . valueOf(createOpts. pluginType),
46- createOpts. serviceType,
47- createOpts. destinationDirectory)
48- }
4953
50- interface CreateOpts {
51- @Option (shortName = " n" ,description = " Plugin Name" )
52- String getPluginName ()
53- @Option (shortName = " t" ,description = " Plugin Type" )
54- String getPluginType ()
55- @Option (shortName = " s" ,description = " Rundeck Service Type" )
56- String getServiceType ()
57- @Option (shortName = " d" ,description = " The directory in which the artifact directory will be generated" )
58- String getDestinationDirectory ()
54+ println generator. generate(this . pluginName,
55+ this . pluginType,
56+ this . serviceType. toString(),
57+ this . destinationDirectory)
58+
59+ return null
5960 }
6061}
0 commit comments