-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
51 lines (45 loc) · 940 Bytes
/
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
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli"
)
var build string = "0" // build number set at compile-time
func main() {
app := cli.NewApp()
app.Name = "Capistrano plugin"
app.Usage = "Capistrano plugin"
app.Action = run
app.Version = fmt.Sprintf("1.0.%s", build)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "tasks",
Usage: "capistrano tasks to run",
EnvVar: "PLUGIN_TASKS",
},
cli.StringFlag{
Name: "private_key",
Usage: "SSH private key",
EnvVar: "CAPISTRANO_PRIVATE_KEY",
},
cli.StringFlag{
Name: "public_key",
Usage: "SSH public key",
EnvVar: "CAPISTRANO_PUBLIC_KEY",
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func run(c *cli.Context) error {
plugin := Plugin{
Config: Config{
Tasks: c.String("tasks"),
PrivateKey: c.String("private_key"),
PublicKey: c.String("public_key"),
},
}
return plugin.Exec()
}