woodpecker/cmd/restart.go

37 lines
800 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-09 23:51:08 +00:00
if len(args) == 5 {
host, owner, repo = parseRepo(args[0])
} else {
host = "unknown"
owner = "unknown"
repo = "unknown"
branch = "unknown"
sha = "unknown"
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
}