etcdctl: Rename Start / StartWithErrors to MustStart

This commit is contained in:
Piotr Tabor 2020-09-09 19:32:50 +02:00
parent c32180d772
commit 7c880e5263
3 changed files with 10 additions and 10 deletions

View File

@ -26,7 +26,7 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
) )
func StartWithError() error { func Start() error {
app := cli.NewApp() app := cli.NewApp()
app.Name = "etcdctl" app.Name = "etcdctl"
app.Version = version.Version app.Version = version.Version
@ -75,8 +75,8 @@ func StartWithError() error {
return app.Run(os.Args) return app.Run(os.Args)
} }
func Start() { func MustStart() {
err := StartWithError() err := Start()
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
os.Exit(1) os.Exit(1)

View File

@ -95,15 +95,15 @@ func init() {
) )
} }
func StartWithError() error { func Start() error {
rootCmd.SetUsageFunc(usageFunc) rootCmd.SetUsageFunc(usageFunc)
// Make help just show the usage // Make help just show the usage
rootCmd.SetHelpTemplate(`{{.UsageString}}`) rootCmd.SetHelpTemplate(`{{.UsageString}}`)
return rootCmd.Execute() return rootCmd.Execute()
} }
func Start() { func MustStart() {
if err := StartWithError(); err != nil { if err := Start(); err != nil {
command.ExitWithError(command.ExitError, err) command.ExitWithError(command.ExitError, err)
} }
} }

View File

@ -39,11 +39,11 @@ func mainWithError() error {
os.Unsetenv(apiEnv) os.Unsetenv(apiEnv)
if len(apiv) == 0 || apiv == "3" { if len(apiv) == 0 || apiv == "3" {
return ctlv3.StartWithError() return ctlv3.Start()
} }
if apiv == "2" { if apiv == "2" {
return ctlv2.StartWithError() return ctlv2.Start()
} }
fmt.Fprintf(os.Stderr, "unsupported API version: %s\n", apiv) fmt.Fprintf(os.Stderr, "unsupported API version: %s\n", apiv)
@ -56,12 +56,12 @@ func main() {
// unset apiEnv to avoid side-effect for future env and flag parsing. // unset apiEnv to avoid side-effect for future env and flag parsing.
os.Unsetenv(apiEnv) os.Unsetenv(apiEnv)
if len(apiv) == 0 || apiv == "3" { if len(apiv) == 0 || apiv == "3" {
ctlv3.Start() ctlv3.MustStart()
return return
} }
if apiv == "2" { if apiv == "2" {
ctlv2.Start() ctlv2.MustStart()
return return
} }