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"
)
func StartWithError() error {
func Start() error {
app := cli.NewApp()
app.Name = "etcdctl"
app.Version = version.Version
@ -75,8 +75,8 @@ func StartWithError() error {
return app.Run(os.Args)
}
func Start() {
err := StartWithError()
func MustStart() {
err := Start()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)

View File

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

View File

@ -39,11 +39,11 @@ func mainWithError() error {
os.Unsetenv(apiEnv)
if len(apiv) == 0 || apiv == "3" {
return ctlv3.StartWithError()
return ctlv3.Start()
}
if apiv == "2" {
return ctlv2.StartWithError()
return ctlv2.Start()
}
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.
os.Unsetenv(apiEnv)
if len(apiv) == 0 || apiv == "3" {
ctlv3.Start()
ctlv3.MustStart()
return
}
if apiv == "2" {
ctlv2.Start()
ctlv2.MustStart()
return
}