Skip to content

Commit

Permalink
pd-ctl: set exit code for invalid command
Browse files Browse the repository at this point in the history
Signed-off-by: Shenjun Ma <mashenjun0902@gmail.com>
  • Loading branch information
mashenjun committed Jan 5, 2021
1 parent e23285f commit 8d1306f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tools/pd-ctl/pdctl/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,30 @@ func hiddenFlag(cmd *cobra.Command) {

// MainStart start main command
func MainStart(args []string) {
startCmd(getMainCmd, args)
if err := startCmd(getMainCmd, args); err != nil {
os.Exit(1)
}
}

// Start start interact command
func Start(args []string) {
startCmd(getInteractCmd, args)
_ = startCmd(getInteractCmd, args)
}

func startCmd(getCmd func([]string) *cobra.Command, args []string) {
func startCmd(getCmd func([]string) *cobra.Command, args []string) error {
rootCmd := getCmd(args)
if len(commandFlags.CAPath) != 0 {
if err := command.InitHTTPSClient(commandFlags.CAPath, commandFlags.CertPath, commandFlags.KeyPath); err != nil {
rootCmd.Println(err)
return
return err
}
}

if err := rootCmd.Execute(); err != nil {
rootCmd.Println(err)
return err
}
return nil
}

func loop() {
Expand Down

0 comments on commit 8d1306f

Please sign in to comment.