mirror of
https://github.com/drone/drone-cli.git
synced 2024-11-26 06:07:05 +01:00
Add drone cron exec cmd (#180)
This commit is contained in:
parent
c270335a61
commit
662f6f4957
@ -13,5 +13,6 @@ var Command = cli.Command{
|
||||
cronDeleteCmd,
|
||||
cronDisableCmd,
|
||||
cronEnableCmd,
|
||||
cronExecCmd,
|
||||
},
|
||||
}
|
||||
|
35
drone/cron/cron_exec.go
Normal file
35
drone/cron/cron_exec.go
Normal file
@ -0,0 +1,35 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/drone/drone-cli/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var cronExecCmd = cli.Command{
|
||||
Name: "exec",
|
||||
Usage: "trigger cron job",
|
||||
ArgsUsage: "[repo/name] [cronjob]",
|
||||
Action: cronExec,
|
||||
}
|
||||
|
||||
func cronExec(c *cli.Context) error {
|
||||
slug := c.Args().First()
|
||||
owner, name, err := internal.ParseRepo(slug)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cron := c.Args().Get(1)
|
||||
if cron == "" {
|
||||
return errors.New("missing cronjob name")
|
||||
}
|
||||
|
||||
return client.CronExec(owner, name, cron)
|
||||
}
|
Loading…
Reference in New Issue
Block a user