From 6e8fd5c8f5dce0ad01389f952fa708005e4d410c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 19 Aug 2024 14:42:51 -0700 Subject: [PATCH] add missing 'err' handling for listener Bonus: show proper help output with no args --- main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 85ea08e..3ec5b6b 100644 --- a/main.go +++ b/main.go @@ -768,7 +768,7 @@ func clientTransport(ctx *cli.Context, tlsMaxVersion uint16, enableTLS bool, hos func checkMain(ctx *cli.Context) { if !ctx.Args().Present() { - cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) + cli.ShowAppHelpAndExit(ctx, 1) } } @@ -1152,6 +1152,9 @@ func sidekickMain(ctx *cli.Context) { } else { listener, err = net.Listen("tcp", addr) } + if err != nil { + console.Fatalln(err) + } go func() { if err := server.Serve(listener); err != nil { console.Fatalln(err) @@ -1186,13 +1189,19 @@ func main() { // Set system resources to maximum. setMaxResources() + cli.HelpFlag = cli.BoolFlag{ + Name: "help, h", + Usage: "show help", + } + app := cli.NewApp() app.Name = os.Args[0] + app.HideHelpCommand = true // Hide `help, h` command, we already have `minio --help`. app.Author = "MinIO, Inc." app.Description = `High-Performance sidecar load-balancer` app.UsageText = "[FLAGS] SITE1 [SITE2..]" app.Version = version - app.Copyright = "(c) 2020-2023 MinIO, Inc." + app.Copyright = "(c) 2020-2024 MinIO, Inc." app.Flags = []cli.Flag{ cli.StringFlag{ Name: "address, a",