diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-08-02 16:10:17 +0800 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-08-02 16:10:17 +0800 |
commit | 3b6f9f7583755e041e76142d7caf7716937907fa (patch) | |
tree | ed7f7281633d97933e4465a2ac0f86d62c9a216e /go/internal/command/command.go | |
parent | 592823d5e25006331b361b36cc61df7802fc1938 (diff) | |
download | gitlab-shell-3b6f9f7583755e041e76142d7caf7716937907fa.tar.gz |
Add Executable struct181-migrate-gitlab-shell-checks-fallback
This struct is responsible for determining the name and
root dir of the executable.
The `RootDir` property will be used to find the config.
The `Name` property will be used to determine what `Command`
and `CommandArgs` to be built.
Diffstat (limited to 'go/internal/command/command.go')
-rw-r--r-- | go/internal/command/command.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/go/internal/command/command.go b/go/internal/command/command.go index 66bed6f..27378aa 100644 --- a/go/internal/command/command.go +++ b/go/internal/command/command.go @@ -11,28 +11,29 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/uploadarchive" "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/uploadpack" "gitlab.com/gitlab-org/gitlab-shell/go/internal/config" + "gitlab.com/gitlab-org/gitlab-shell/go/internal/executable" ) type Command interface { Execute() error } -func New(arguments []string, config *config.Config, readWriter *readwriter.ReadWriter) (Command, error) { - args, err := commandargs.Parse(arguments) +func New(e *executable.Executable, arguments []string, config *config.Config, readWriter *readwriter.ReadWriter) (Command, error) { + args, err := commandargs.Parse(e, arguments) if err != nil { return nil, err } - if cmd := buildCommand(args, config, readWriter); cmd != nil { + if cmd := buildCommand(e, args, config, readWriter); cmd != nil { return cmd, nil } - return &fallback.Command{RootDir: config.RootDir, Args: args}, nil + return &fallback.Command{Executable: e, RootDir: config.RootDir, Args: args}, nil } -func buildCommand(args commandargs.CommandArgs, config *config.Config, readWriter *readwriter.ReadWriter) Command { - switch args.Executable() { - case commandargs.GitlabShell: +func buildCommand(e *executable.Executable, args commandargs.CommandArgs, config *config.Config, readWriter *readwriter.ReadWriter) Command { + switch e.Name { + case executable.GitlabShell: return buildShellCommand(args.(*commandargs.Shell), config, readWriter) } |