diff --git a/app/cmd/plugin_create.go b/app/cmd/plugin_create.go new file mode 100644 index 0000000000000000000000000000000000000000..06523ad8ce669cbe0e0270be1c5f14cd65e2a31f --- /dev/null +++ b/app/cmd/plugin_create.go @@ -0,0 +1,44 @@ +package cmd + +import ( + "os" + "os/exec" + "syscall" + + "github.com/jenkins-zh/jenkins-cli/app/i18n" + + "github.com/spf13/cobra" +) + +// PluginCreateOptions for the plugin create command +type PluginCreateOptions struct { + Debug bool +} + +var pluginCreateOptions PluginCreateOptions + +func init() { + pluginCmd.AddCommand(pluginCreateCmd) + pluginCreateCmd.Flags().BoolVar(&pluginCreateOptions.Debug, "debug-output", false, + i18n.T("If you want the maven output the debug info")) +} + +var pluginCreateCmd = &cobra.Command{ + Use: "create", + Short: i18n.T("Create a plugin project from the archetypes"), + Long: i18n.T(`Create a plugin project from the archetypes +Plugin tutorial is here https://jenkins.io/doc/developer/tutorial/`), + RunE: func(cmd *cobra.Command, _ []string) (err error) { + binary, err := exec.LookPath("mvn") + if err == nil { + env := os.Environ() + + mvnArgs := []string{"mvn", "archetype:generate", "-U", `-Dfilter=io.jenkins.archetypes:`} + if pluginCreateOptions.Debug { + mvnArgs = append(mvnArgs, "-X") + } + err = syscall.Exec(binary, mvnArgs, env) + } + return + }, +} diff --git a/app/i18n/jcli/zh_CN/LC_MESSAGES/jcli.po b/app/i18n/jcli/zh_CN/LC_MESSAGES/jcli.po index a1099eb707d926c34edd30c049c68ba4740e360d..b72dd3fe6bcab16095d6aee00b2fba731a3cd0e8 100644 --- a/app/i18n/jcli/zh_CN/LC_MESSAGES/jcli.po +++ b/app/i18n/jcli/zh_CN/LC_MESSAGES/jcli.po @@ -24,7 +24,11 @@ msgstr "" #: app/cmd/plugin_check.go:27 app/cmd/plugin_check.go:28 msgid "Check update center server" -msgstr "" +msgstr "检查插件更新中心" + +#: app/cmd/plugin_create.go:18 +msgid "Create a plugin project from the archetypes" +msgstr "根据 Maven 骨架创建插件工程" #: app/cmd/center_download.go:44 msgid "Download Jenkins from a mirror site. You can get more mirror sites from https://jenkins-zh.cn/tutorial/management/mirror/" @@ -90,6 +94,11 @@ msgstr "" msgid "Input a job in your Jenkins" msgstr "" +#: app/cmd/plugin_create.go:19 +msgid "Create a plugin project from the archetypes\n" + "Plugin tutorial is here https://jenkins.io/doc/developer/tutorial/" +msgstr "" + #: app/cmd/job_log.go:38 msgid "Print the job's log of your Jenkins" msgstr "输出任务的日志" @@ -228,7 +237,7 @@ msgstr "设置更新中心为一个镜像地址" #: app/cmd/plugin_search.go:33 app/cmd/plugin_search.go:34 msgid "Print the plugins of your Jenkins" -msgstr "列出你的 Jenkins 中的插件" +msgstr "搜索插件" #: app/cmd/plugin_upload.go:39 msgid "Whether show the upload progress"