提交 9028069b 编写于 作者: LinuxSuRen's avatar LinuxSuRen

Print the help text when got error input

上级 e039d2e9
......@@ -25,12 +25,13 @@ func init() {
}
var jobCmd = &cobra.Command{
Use: "job",
Use: "job -n",
Short: "Print the job of your Jenkins",
Long: `Print the job of your Jenkins`,
Run: func(cmd *cobra.Command, args []string) {
if jobOption.Name == "" {
log.Fatal("need a name")
cmd.Help()
return
}
jenkins := getCurrentJenkins()
......
package cmd
import (
"log"
"github.com/linuxsuren/jenkins-cli/client"
"github.com/spf13/cobra"
)
......@@ -12,12 +10,13 @@ func init() {
}
var jobBuildCmd = &cobra.Command{
Use: "build",
Use: "build -n",
Short: "Build the job of your Jenkins",
Long: `Build the job of your Jenkins`,
Run: func(cmd *cobra.Command, args []string) {
if jobOption.Name == "" {
log.Fatal("need a name")
cmd.Help()
return
}
jenkins := getCurrentJenkins()
......
......@@ -20,12 +20,13 @@ func init() {
}
var jobLogCmd = &cobra.Command{
Use: "log",
Use: "log -n",
Short: "Print the job of your Jenkins",
Long: `Print the job of your Jenkins`,
Run: func(cmd *cobra.Command, args []string) {
if jobOption.Name == "" {
log.Fatal("need a name")
cmd.Help()
return
}
jenkins := getCurrentJenkins()
......
......@@ -20,12 +20,13 @@ func init() {
}
var jobSearchCmd = &cobra.Command{
Use: "search",
Use: "search <keyword>",
Short: "Print the job of your Jenkins",
Long: `Print the job of your Jenkins`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
log.Fatal("need a keyword")
cmd.Help()
return
}
keyword := args[0]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册