summaryrefslogtreecommitdiff
path: root/cmd/gitlab-shell/main.go
diff options
context:
space:
mode:
authorIgor <idrozdov@gitlab.com>2019-10-21 16:25:53 +0000
committerIgor <idrozdov@gitlab.com>2019-10-21 16:25:53 +0000
commit629e3bf9c31687f7b824cf29ba07ad2ce402e280 (patch)
tree0f80f7394231d39970f23a08ba9ba2ce7051e22c /cmd/gitlab-shell/main.go
parent7d5229db263a62661653431881bef8b46984d0de (diff)
parentede41ee451dd0aa6d0ecd958c7fadbdb3b63f3e4 (diff)
downloadgitlab-shell-629e3bf9c31687f7b824cf29ba07ad2ce402e280.tar.gz
Merge branch '173-move-go-code-up-one-level' into 'master'
Move Go code up one level See merge request gitlab-org/gitlab-shell!350
Diffstat (limited to 'cmd/gitlab-shell/main.go')
-rw-r--r--cmd/gitlab-shell/main.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/cmd/gitlab-shell/main.go b/cmd/gitlab-shell/main.go
new file mode 100644
index 0000000..148c652
--- /dev/null
+++ b/cmd/gitlab-shell/main.go
@@ -0,0 +1,44 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/config"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/executable"
+)
+
+func main() {
+ readWriter := &readwriter.ReadWriter{
+ Out: os.Stdout,
+ In: os.Stdin,
+ ErrOut: os.Stderr,
+ }
+
+ executable, err := executable.New(executable.GitlabShell)
+ if err != nil {
+ fmt.Fprintln(readWriter.ErrOut, "Failed to determine executable, exiting")
+ os.Exit(1)
+ }
+
+ config, err := config.NewFromDir(executable.RootDir)
+ if err != nil {
+ fmt.Fprintln(readWriter.ErrOut, "Failed to read config, exiting")
+ os.Exit(1)
+ }
+
+ cmd, err := command.New(executable, os.Args[1:], config, readWriter)
+ if err != nil {
+ // For now this could happen if `SSH_CONNECTION` is not set on
+ // the environment
+ fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
+ os.Exit(1)
+ }
+
+ if err = cmd.Execute(); err != nil {
+ fmt.Fprintf(readWriter.ErrOut, "%v\n", err)
+ os.Exit(1)
+ }
+}