From d73e37579cd1c225fc79628458c0aa03fda78053 Mon Sep 17 00:00:00 2001 From: Zhao Xiaojie Date: Mon, 1 Jul 2019 22:06:19 +0800 Subject: [PATCH] Add validation for config args --- app/cmd/config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/cmd/config.go b/app/cmd/config.go index a042a6d..5166cc7 100644 --- a/app/cmd/config.go +++ b/app/cmd/config.go @@ -1,6 +1,7 @@ package cmd import ( + "errors" "fmt" "io/ioutil" "log" @@ -35,6 +36,13 @@ var configCmd = &cobra.Command{ Use: "config", Short: "Manage the config of jcli", Long: `Manage the config of jcli`, + Args: func(cmd *cobra.Command, args []string) (err error) { + if !configOptions.Show && !configOptions.Generate && + !configOptions.List && configOptions.Current == "" { + err = errors.New("need arguments") + } + return + }, Run: func(cmd *cobra.Command, args []string) { current := getCurrentJenkins() if configOptions.Show { -- GitLab