From c36f23b072319ab5e4744088cbff4deab360f22b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 6 Mar 2024 01:56:14 -0500 Subject: [PATCH] fix: add missing cron:set command The code existed but somehow it wasn't exposed as a command. Closes #6655 --- docs/processes/scheduled-cron-tasks.md | 7 ++++--- plugins/cron/Makefile | 2 +- plugins/cron/src/commands/commands.go | 3 ++- plugins/cron/src/subcommands/subcommands.go | 13 +++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/docs/processes/scheduled-cron-tasks.md b/docs/processes/scheduled-cron-tasks.md index c82f59c3b..fcf07b2b6 100644 --- a/docs/processes/scheduled-cron-tasks.md +++ b/docs/processes/scheduled-cron-tasks.md @@ -4,9 +4,10 @@ > New as of 0.23.0 ``` -cron:list [--format json|stdout] # List scheduled cron tasks for an app -cron:report [] [] # Display report about an app -cron:run [--detach] # Run a cron task on the fly +cron:list [--format json|stdout] # List scheduled cron tasks for an app +cron:report [] [] # Display report about an app +cron:run [--detach] # Run a cron task on the fly +cron:set [--global|] # Set or clear a cron property for an app ``` ## Usage diff --git a/plugins/cron/Makefile b/plugins/cron/Makefile index 914884ed1..e0e1dbe33 100644 --- a/plugins/cron/Makefile +++ b/plugins/cron/Makefile @@ -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 diff --git a/plugins/cron/src/commands/commands.go b/plugins/cron/src/commands/commands.go index 5795ee3e0..36b6b89a5 100644 --- a/plugins/cron/src/commands/commands.go +++ b/plugins/cron/src/commands/commands.go @@ -20,7 +20,8 @@ Additional commands:` helpContent = ` cron:list [--format json|stdout], List scheduled cron tasks for an app cron:report [] [], Display report about an app - cron:run [--detach], Run a cron task on the fly` + cron:run [--detach], Run a cron task on the fly + cron:set [--global|] , Set or clear a cron property for an app` ) func main() { diff --git a/plugins/cron/src/subcommands/subcommands.go b/plugins/cron/src/subcommands/subcommands.go index 94ff0c191..f536f763f 100644 --- a/plugins/cron/src/subcommands/subcommands.go +++ b/plugins/cron/src/subcommands/subcommands.go @@ -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) }