1
0
mirror of https://github.com/drone/drone-cli.git synced 2024-11-23 09:21:56 +01:00
drone-cli/drone/cron/cron_enable.go

40 lines
734 B
Go
Raw Normal View History

2018-08-07 01:29:03 +02:00
package cron
import (
2018-10-22 04:54:57 +02:00
"errors"
2018-08-07 01:29:03 +02:00
"github.com/drone/drone-cli/drone/internal"
2018-10-22 04:54:57 +02:00
"github.com/drone/drone-go/drone"
2018-08-07 01:29:03 +02:00
"github.com/urfave/cli"
)
2018-09-21 01:04:58 +02:00
var cronEnableCmd = cli.Command{
Name: "enable",
Usage: "enable cron jobs",
2018-10-22 04:54:57 +02:00
ArgsUsage: "[repo/name] [cronjob]",
2018-09-21 01:04:58 +02:00
Action: cronEnable,
2018-08-07 01:29:03 +02:00
}
2018-09-21 01:04:58 +02:00
func cronEnable(c *cli.Context) error {
2018-08-07 01:29:03 +02:00
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
}
2018-10-22 04:54:57 +02:00
cron := c.Args().Get(1)
if cron == "" {
return errors.New("missing cronjob name")
}
disabled := false
in := &drone.CronPatch{
Disabled: &disabled,
}
_, err = client.CronUpdate(owner, name, cron, in)
return err
2018-08-07 01:29:03 +02:00
}