forked from vmware-archive/fly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (47 loc) · 1.85 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"net"
"os"
"github.com/concourse/fly/commands"
"github.com/concourse/fly/rc"
"github.com/concourse/fly/ui"
"github.com/concourse/go-concourse/concourse"
"github.com/jessevdk/go-flags"
)
func main() {
parser := flags.NewParser(&commands.Fly, flags.HelpFlag|flags.PassDoubleDash)
parser.NamespaceDelimiter = "-"
_, err := parser.Parse()
if err != nil {
if err == concourse.ErrUnauthorized {
fmt.Fprintln(os.Stderr, "not authorized. run the following to log in:")
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, " "+ui.Embolden("fly -t %s login", commands.Fly.Target))
fmt.Fprintln(os.Stderr, "")
} else if err == rc.ErrNoTargetSpecified {
fmt.Fprintln(os.Stderr, "no target specified. specify the target with "+ui.Embolden("-t")+" or log in like so:")
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, " "+ui.Embolden("fly -t (alias) login -c (concourse url)"))
fmt.Fprintln(os.Stderr, "")
} else if versionErr, ok := err.(rc.ErrVersionMismatch); ok {
fmt.Fprintln(os.Stderr, versionErr.Error())
fmt.Fprintln(os.Stderr, ui.WarningColor("cowardly refusing to run due to significant version discrepancy"))
} else if netErr, ok := err.(net.Error); ok {
fmt.Fprintf(os.Stderr, "could not reach the Concourse server called %s:\n", ui.Embolden("%s", commands.Fly.Target))
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, " "+ui.Embolden("%s", netErr))
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, "is the targeted Concourse running? better go catch it lol")
} else if err == commands.ErrShowHelpMessage {
helpParser := flags.NewParser(&commands.Fly, flags.HelpFlag)
helpParser.NamespaceDelimiter = "-"
helpParser.ParseArgs([]string{"-h"})
helpParser.WriteHelp(os.Stdout)
os.Exit(0)
} else {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
}
os.Exit(1)
}
}