mirror of
https://github.com/drone/drone-cli.git
synced 2024-11-23 01:11:57 +01:00
36 lines
603 B
Go
36 lines
603 B
Go
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)
|
|
}
|