-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgit.go
More file actions
81 lines (62 loc) · 1.63 KB
/
git.go
File metadata and controls
81 lines (62 loc) · 1.63 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package parser
import (
"fmt"
"github.com/deis/workflow-cli/cmd"
docopt "github.com/docopt/docopt-go"
)
// Git routes git commands to their specific function.
func Git(argv []string, cmdr cmd.Commander) error {
usage := `
Valid commands for git:
git:remote Adds git remote of application to repository
git:remove Removes git remote of application from repository
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "git:remote":
return gitRemote(argv, cmdr)
case "git:remove":
return gitRemove(argv, cmdr)
case "git":
fmt.Print(usage)
return nil
default:
PrintUsage(cmdr)
return nil
}
}
func gitRemote(argv []string, cmdr cmd.Commander) error {
usage := `
Adds git remote of application to repository
Usage: deis git:remote [options]
Options:
-a --app=<app>
the uniquely identifiable name for the application.
-r --remote=REMOTE
name of remote to create. [default: deis]
-f --force
overwrite remote of the given name if it already exists.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
remote := safeGetValue(args, "--remote")
force := args["--force"].(bool)
return cmdr.GitRemote(app, remote, force)
}
func gitRemove(argv []string, cmdr cmd.Commander) error {
usage := `
Removes git remotes of application from repository.
Usage: deis git:remove [options]
Options:
-a --app=<app>
the uniquely identifiable name for the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
return cmdr.GitRemove(safeGetValue(args, "--app"))
}