未验证 提交 f925117a 编写于 作者: LinuxSuRen's avatar LinuxSuRen 提交者: GitHub

Add support to create a plugin (#255)

* Add support to create a plugin

* Use syscal instead of execute

* Add i18n entry

* Fix the mvn execution

* Add comment for PluginCreateOptions
上级 24cee7dc
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
},
}
......@@ -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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册