MCPcopy Create free account
hub / github.com/compozy/agh / newAutomationJobsUpdateCommand

Function newAutomationJobsUpdateCommand

internal/cli/automation.go:254–307  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

252}
253
254func newAutomationJobsUpdateCommand(deps commandDeps) *cobra.Command {
255 var (
256 name string
257 agentName string
258 workspaceRef string
259 prompt string
260 scheduleRaw string
261 retryRaw string
262 enabled bool
263 )
264
265 cmd := &cobra.Command{
266 Use: automationUpdateIDValue,
267 Short: "Update an automation job",
268 Args: exactOneNonBlankArg(),
269 RunE: func(cmd *cobra.Command, args []string) error {
270 client, err := clientFromDeps(deps)
271 if err != nil {
272 return err
273 }
274
275 request, err := buildAutomationJobUpdateRequest(cmd, client, automationJobUpdateInput{
276 Name: name,
277 AgentName: agentName,
278 WorkspaceRef: workspaceRef,
279 Prompt: prompt,
280 ScheduleRaw: scheduleRaw,
281 RetryRaw: retryRaw,
282 Enabled: enabled,
283 })
284 if err != nil {
285 return err
286 }
287 if !request.HasChanges() {
288 return errors.New("cli: automation job update requires at least one change flag")
289 }
290
291 updated, err := client.UpdateAutomationJob(cmd.Context(), args[0], request)
292 if err != nil {
293 return err
294 }
295 return writeCommandOutput(cmd, automationJobBundle(updated))
296 },
297 }
298 cmd.Flags().StringVar(&name, automationNameKey, "", "Update the job name")
299 cmd.Flags().StringVar(&agentName, "agent", "", "Update the agent definition")
300 cmd.Flags().StringVar(&workspaceRef, "workspace", "", "Update the workspace path, name, or ID")
301 cmd.Flags().StringVar(&prompt, automationPromptKey, "", "Update the prompt body")
302 cmd.Flags().StringVar(&scheduleRaw, "schedule", "", "Update the schedule spec")
303 cmd.Flags().
304 StringVar(&retryRaw, automationRetryKey, "", `Update retry policy: "none", "backoff", or "backoff:<max_retries>:<base_delay>"`)
305 cmd.Flags().BoolVar(&enabled, automationEnabledKey, false, "Update the enabled state")
306 return cmd
307}
308
309func buildAutomationJobUpdateRequest(
310 cmd *cobra.Command,

Callers 1

newAutomationJobsCommandFunction · 0.85

Calls 7

exactOneNonBlankArgFunction · 0.85
clientFromDepsFunction · 0.85
writeCommandOutputFunction · 0.85
automationJobBundleFunction · 0.85
UpdateAutomationJobMethod · 0.65
HasChangesMethod · 0.45

Tested by

no test coverage detected