From 3e9a99dd5507478a8d0fb798e569140c4c44c11a Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Wed, 4 Feb 2026 16:29:24 -0500 Subject: [PATCH] cmd/loop: factor newRootCommand --- cmd/loop/main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/loop/main.go b/cmd/loop/main.go index d12fdea9..8921e1bb 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -201,7 +201,15 @@ func fatal(err error) { } func main() { - rootCmd := &cli.Command{ + rootCmd := newRootCommand() + if err := rootCmd.Run(context.Background(), os.Args); err != nil { + fatal(err) + } +} + +// newRootCommand constructs the CLI root command for loop. +func newRootCommand() *cli.Command { + return &cli.Command{ Name: "loop", Usage: "control plane for your loopd", Version: loop.RichVersion(), @@ -222,10 +230,6 @@ func main() { return cli.ShowRootCommandHelp(cmd) }, } - - if err := rootCmd.Run(context.Background(), os.Args); err != nil { - fatal(err) - } } // getClient establishes a SwapClient RPC connection and returns the client and