summaryrefslogtreecommitdiff
path: root/go/internal/command/command.go
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-05-22 12:28:25 +0000
committerNick Thomas <nick@gitlab.com>2019-05-22 12:28:25 +0000
commit48142b98ca9565698632c44e72e29e22b9c923c3 (patch)
treef2d007cb411667045ffc26278d7345bf19f362e9 /go/internal/command/command.go
parent58d8c7691ac52c00dfebe2154e793c8fccc46aa0 (diff)
parentb77a375205af394945de99c3f7318292510c3245 (diff)
downloadgitlab-shell-48142b98ca9565698632c44e72e29e22b9c923c3.tar.gz
Merge branch 'id-go-refactorings' into 'master'
Refactor execution and parsing logic in Go's implementation See merge request gitlab-org/gitlab-shell!302
Diffstat (limited to 'go/internal/command/command.go')
-rw-r--r--go/internal/command/command.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/go/internal/command/command.go b/go/internal/command/command.go
index 560e0b2..0ceb7fc 100644
--- a/go/internal/command/command.go
+++ b/go/internal/command/command.go
@@ -10,10 +10,10 @@ import (
)
type Command interface {
- Execute(*readwriter.ReadWriter) error
+ Execute() error
}
-func New(arguments []string, config *config.Config) (Command, error) {
+func New(arguments []string, config *config.Config, readWriter *readwriter.ReadWriter) (Command, error) {
args, err := commandargs.Parse(arguments)
if err != nil {
@@ -21,18 +21,18 @@ func New(arguments []string, config *config.Config) (Command, error) {
}
if config.FeatureEnabled(string(args.CommandType)) {
- return buildCommand(args, config), nil
+ return buildCommand(args, config, readWriter), nil
}
return &fallback.Command{RootDir: config.RootDir, Args: arguments}, nil
}
-func buildCommand(args *commandargs.CommandArgs, config *config.Config) Command {
+func buildCommand(args *commandargs.CommandArgs, config *config.Config, readWriter *readwriter.ReadWriter) Command {
switch args.CommandType {
case commandargs.Discover:
- return &discover.Command{Config: config, Args: args}
+ return &discover.Command{Config: config, Args: args, ReadWriter: readWriter}
case commandargs.TwoFactorRecover:
- return &twofactorrecover.Command{Config: config, Args: args}
+ return &twofactorrecover.Command{Config: config, Args: args, ReadWriter: readWriter}
}
return nil