(cmd *cobra.Command, input taskUpdateInput)
| 547 | } |
| 548 | |
| 549 | func buildTaskUpdateRequest(cmd *cobra.Command, input taskUpdateInput) (UpdateTaskRequest, error) { |
| 550 | request := UpdateTaskRequest{} |
| 551 | if cmd.Flags().Changed(taskTitleKey) { |
| 552 | trimmed := strings.TrimSpace(input.Title) |
| 553 | if trimmed == "" { |
| 554 | return UpdateTaskRequest{}, errors.New("cli: --title cannot be blank") |
| 555 | } |
| 556 | request.Title = new(trimmed) |
| 557 | } |
| 558 | if cmd.Flags().Changed(taskDescriptionKey) { |
| 559 | request.Description = new(strings.TrimSpace(input.Description)) |
| 560 | } |
| 561 | if cmd.Flags().Changed("priority") { |
| 562 | priority, err := parseOptionalTaskPriority(input.PriorityRaw) |
| 563 | if err != nil { |
| 564 | return UpdateTaskRequest{}, err |
| 565 | } |
| 566 | request.Priority = &priority |
| 567 | } |
| 568 | if cmd.Flags().Changed("metadata") { |
| 569 | metadata, err := parseJSONFlag("metadata", input.MetadataRaw) |
| 570 | if err != nil { |
| 571 | return UpdateTaskRequest{}, err |
| 572 | } |
| 573 | request.Metadata = &metadata |
| 574 | } |
| 575 | if input.AutoEnqueueSet { |
| 576 | autoEnqueue := input.AutoEnqueueOnReady |
| 577 | request.AutoEnqueueOnReady = &autoEnqueue |
| 578 | } |
| 579 | if cmd.Flags().Changed("channel") { |
| 580 | if err := validateTaskChannelFlag(input.NetworkRaw); err != nil { |
| 581 | return UpdateTaskRequest{}, err |
| 582 | } |
| 583 | request.NetworkChannel = new(strings.TrimSpace(input.NetworkRaw)) |
| 584 | } |
| 585 | |
| 586 | ownerChanged := cmd.Flags().Changed("owner-kind") || cmd.Flags().Changed("owner-ref") |
| 587 | if input.ClearOwner && ownerChanged { |
| 588 | return UpdateTaskRequest{}, errors.New( |
| 589 | "cli: --clear-owner cannot be combined with --owner-kind or --owner-ref", |
| 590 | ) |
| 591 | } |
| 592 | if ownerChanged { |
| 593 | owner, err := parseRequiredTaskOwnership(input.OwnerKindRaw, input.OwnerRef) |
| 594 | if err != nil { |
| 595 | return UpdateTaskRequest{}, err |
| 596 | } |
| 597 | request.Owner = owner |
| 598 | } |
| 599 | if input.ClearOwner { |
| 600 | request.ClearOwner = true |
| 601 | } |
| 602 | return request, nil |
| 603 | } |
| 604 | |
| 605 | func newTaskPublishCommand(deps commandDeps) *cobra.Command { |
| 606 | return newTaskExecutionCommand( |
no test coverage detected