1
0
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:
Chris Raborg 2021-06-22 14:31:38 -04:00 committed by GitHub
parent c270335a61
commit 662f6f4957
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

@ -13,5 +13,6 @@ var Command = cli.Command{
cronDeleteCmd,
cronDisableCmd,
cronEnableCmd,
cronExecCmd,
},
}

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)
}