summaryrefslogtreecommitdiff
path: root/go/internal/command/discover/discover.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/internal/command/discover/discover.go')
-rw-r--r--go/internal/command/discover/discover.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/go/internal/command/discover/discover.go b/go/internal/command/discover/discover.go
index 8ad2868..9bb442f 100644
--- a/go/internal/command/discover/discover.go
+++ b/go/internal/command/discover/discover.go
@@ -4,7 +4,7 @@ import (
"fmt"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs"
- "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/reporting"
+ "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/go/internal/gitlabnet/discover"
)
@@ -14,16 +14,16 @@ type Command struct {
Args *commandargs.CommandArgs
}
-func (c *Command) Execute(reporter *reporting.Reporter) error {
+func (c *Command) Execute(readWriter *readwriter.ReadWriter) error {
response, err := c.getUserInfo()
if err != nil {
return fmt.Errorf("Failed to get username: %v", err)
}
if response.IsAnonymous() {
- fmt.Fprintf(reporter.Out, "Welcome to GitLab, Anonymous!\n")
+ fmt.Fprintf(readWriter.Out, "Welcome to GitLab, Anonymous!\n")
} else {
- fmt.Fprintf(reporter.Out, "Welcome to GitLab, @%s!\n", response.Username)
+ fmt.Fprintf(readWriter.Out, "Welcome to GitLab, @%s!\n", response.Username)
}
return nil
@@ -35,13 +35,5 @@ func (c *Command) getUserInfo() (*discover.Response, error) {
return nil, err
}
- if c.Args.GitlabKeyId != "" {
- return client.GetByKeyId(c.Args.GitlabKeyId)
- } else if c.Args.GitlabUsername != "" {
- return client.GetByUsername(c.Args.GitlabUsername)
- } else {
- // There was no 'who' information, this matches the ruby error
- // message.
- return nil, fmt.Errorf("who='' is invalid")
- }
+ return client.GetByCommandArgs(c.Args)
}