fix: add missing cron:set command

The code existed but somehow it wasn't exposed as a command.

Closes #6655
This commit is contained in:
Jose Diaz-Gonzalez
2024-03-06 01:56:14 -05:00
parent 66623ba2af
commit c36f23b072
4 changed files with 20 additions and 5 deletions

View File

@@ -4,9 +4,10 @@
> New as of 0.23.0
```
cron:list <app> [--format json|stdout] # List scheduled cron tasks for an app
cron:report [<app>] [<flag>] # Display report about an app
cron:run <app> <cron_id> [--detach] # Run a cron task on the fly
cron:list <app> [--format json|stdout] # List scheduled cron tasks for an app
cron:report [<app>] [<flag>] # Display report about an app
cron:run <app> <cron_id> [--detach] # Run a cron task on the fly
cron:set [--global|<app>] <key> <value> # Set or clear a cron property for an app
```
## Usage

View File

@@ -1,4 +1,4 @@
SUBCOMMANDS = subcommands/list subcommands/report subcommands/run
SUBCOMMANDS = subcommands/list subcommands/report subcommands/run subcommands/set
TRIGGERS = triggers/cron-get-property
BUILD = commands subcommands triggers
PLUGIN_NAME = cron

View File

@@ -20,7 +20,8 @@ Additional commands:`
helpContent = `
cron:list <app> [--format json|stdout], List scheduled cron tasks for an app
cron:report [<app>] [<flag>], Display report about an app
cron:run <app> <cron_id> [--detach], Run a cron task on the fly`
cron:run <app> <cron_id> [--detach], Run a cron task on the fly
cron:set [--global|<app>] <key> <value>, Set or clear a cron property for an app`
)
func main() {

View File

@@ -40,6 +40,19 @@ func main() {
appName := args.Arg(0)
cronID := args.Arg(1)
err = cron.CommandRun(appName, cronID, *detached)
case "set":
args := flag.NewFlagSet("cron:set", flag.ExitOnError)
global := args.Bool("global", false, "--global: set a global property")
args.Parse(os.Args[2:])
appName := args.Arg(0)
property := args.Arg(1)
value := args.Arg(2)
if *global {
appName = "--global"
property = args.Arg(0)
value = args.Arg(1)
}
err = cron.CommandSet(appName, property, value)
default:
err = fmt.Errorf("Invalid plugin subcommand call: %s", subcommand)
}