From c9010a3016a3295bf90d025403b2e79aae6922b7 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Mon, 16 Mar 2020 17:17:56 +0100 Subject: [PATCH] move commands to its scope --- pkg/command/root.go | 13 +++++++++---- pkg/command/server.go | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/command/root.go b/pkg/command/root.go index a14b056079..895070379e 100644 --- a/pkg/command/root.go +++ b/pkg/command/root.go @@ -35,10 +35,7 @@ func Execute() error { return ParseConfig(c, cfg) }, - Commands: []*cli.Command{ - Server(cfg), - Health(cfg), - }, + Commands: GetCommands(cfg), } cli.HelpFlag = &cli.BoolFlag{ @@ -54,6 +51,14 @@ func Execute() error { return app.Run(os.Args) } +// GetCommands undocummented +func GetCommands(cfg *config.Config) []*cli.Command { + return []*cli.Command{ + Server(cfg), + Health(cfg), + } +} + // NewLogger initializes a service-specific logger instance. func NewLogger(cfg *config.Config) log.Logger { return log.NewLogger( diff --git a/pkg/command/server.go b/pkg/command/server.go index ad99e9ecb0..a6245b2a52 100644 --- a/pkg/command/server.go +++ b/pkg/command/server.go @@ -31,8 +31,6 @@ func Server(cfg *config.Config) *cli.Command { Usage: "Start integrated server", Flags: flagset.ServerWithConfig(cfg), Before: func(ctx *cli.Context) error { - // commands are loaded asynchronously, config gets lost along the way, - // therefore we need to run this routine again, since a new config is passed each time. ParseConfig(ctx, cfg) if cfg.HTTP.Root != "/" {