From 96ccadc70f844b5453c75ce264abd06d673daa83 Mon Sep 17 00:00:00 2001 From: Roxie Gibson Date: Wed, 20 Oct 2021 09:45:38 +0100 Subject: [PATCH] refactor: move making app struct to construct func makes the code cleaner and easier to grab the app struct for testing --- cli/cli.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index d1cf16948..7293f0894 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -41,8 +41,7 @@ var DebugFlag = &cli.BoolFlag{ Usage: "Show DEBUG messages", } -// RunApp runs CLI abra app. -func RunApp(version, commit string) { +func newAbraApp(version, commit string) *cli.App { app := &cli.App{ Name: "abra", Usage: `The Co-op Cloud command-line utility belt 🎩🐇 @@ -108,6 +107,12 @@ func RunApp(version, commit string) { return nil } + return app +} + +// RunApp runs CLI abra app. +func RunApp(version, commit string) { + app := newAbraApp(version, commit) if err := app.Run(os.Args); err != nil { logrus.Fatal(err)