-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor v2 cmds by removing duplicate code
Signed-off-by: Shubham Jain <shubhamkjain@outlook.com>
- Loading branch information
1 parent
590b58a
commit 1786447
Showing
39 changed files
with
989 additions
and
1,192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"github.com/spf13/cobra" | ||
"go.keploy.io/server/config" | ||
updateSvc "go.keploy.io/server/pkg/service/update" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// create interface for cobra commands and subcommands | ||
type Cmd interface { | ||
GetCmd(*zap.Logger) *cobra.Command | ||
type HookFunc func(context.Context, *zap.Logger, *config.Config, Services) *cobra.Command | ||
|
||
// Registered holds the registered command hooks | ||
var Registered map[string]HookFunc | ||
|
||
func Register(name string, f HookFunc) { | ||
if Registered == nil { | ||
Registered = make(map[string]HookFunc) | ||
} | ||
Registered[name] = f | ||
} | ||
|
||
// create global array of registered commands | ||
var RegisteredCmds []Cmd | ||
// Services holds the services required by the commands | ||
type Services struct { | ||
Updater updateSvc.Updater | ||
} | ||
|
||
func NewServices(updater updateSvc.Updater) Services { | ||
return Services{Updater: updater} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.