createField creates a single field in the project
(ctx context.Context, projectNumber int, owner, name, dataType string, options []string, verbose bool)
| 540 | |
| 541 | // createField creates a single field in the project |
| 542 | func createField(ctx context.Context, projectNumber int, owner, name, dataType string, options []string, verbose bool) error { |
| 543 | projectLog.Printf("Creating field: name=%s, type=%s", name, dataType) |
| 544 | |
| 545 | args := []string{ |
| 546 | "project", "field-create", strconv.Itoa(projectNumber), |
| 547 | "--owner", owner, |
| 548 | "--name", name, |
| 549 | "--data-type", dataType, |
| 550 | } |
| 551 | |
| 552 | // Add options for SINGLE_SELECT fields |
| 553 | if dataType == "SINGLE_SELECT" && len(options) > 0 { |
| 554 | for _, option := range options { |
| 555 | args = append(args, "--single-select-options", option) |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | _, err := workflow.RunGH(fmt.Sprintf("Creating field %s...", name), args...) |
| 560 | if err != nil { |
| 561 | return fmt.Errorf("failed to create field: %w", err) |
| 562 | } |
| 563 | |
| 564 | return nil |
| 565 | } |
| 566 | |
| 567 | // ensureStatusOption ensures a status option exists in the project's Status field |
| 568 | func ensureStatusOption(ctx context.Context, projectURL, optionName string, verbose bool) error { |
no test coverage detected