woodpecker/cli/restart.go

40 lines
810 B
Go
Raw Normal View History

2014-07-16 07:34:23 +00:00
package main
import (
"github.com/codegangsta/cli"
2014-08-09 23:51:08 +00:00
"github.com/drone/drone/client"
2014-07-16 07:34:23 +00:00
)
// NewRestartCommand returns the CLI command for "restart".
func NewRestartCommand() cli.Command {
return cli.Command{
Name: "restart",
2014-08-08 05:22:04 +00:00
Usage: "restarts a build on the server",
2014-07-16 07:34:23 +00:00
Flags: []cli.Flag{},
Action: func(c *cli.Context) {
handle(c, restartCommandFunc)
},
}
}
// restartCommandFunc executes the "restart" command.
2014-08-09 23:51:08 +00:00
func restartCommandFunc(c *cli.Context, client *client.Client) error {
var host, owner, repo, branch, sha string
var args = c.Args()
2014-07-16 07:34:23 +00:00
2014-08-14 19:36:04 +00:00
if len(args) != 0 {
2014-08-09 23:51:08 +00:00
host, owner, repo = parseRepo(args[0])
2014-08-14 19:36:04 +00:00
}
switch len(args) {
case 2:
branch = "master"
sha = args[1]
case 3,4,5:
branch = args[1]
sha = args[2]
2014-07-16 07:34:23 +00:00
}
2014-08-09 23:51:08 +00:00
return client.Commits.Rebuild(host, owner, repo, branch, sha)
2014-07-16 07:34:23 +00:00
}