Add issue field support to gh CLI - #13948
Conversation
…field Issue field values live on the issue itself (like labels and assignees), so: - Read: ProjectV2ItemIssueFieldValue is surfaced through the project item field values and exported by gh project item-list --format json. - Write: new issue-scoped command 'gh issue edit-field <issue> --field-id ...' sets/clears a typed value via updateIssueFieldValue, keeping gh project item-edit for project-item field writes. - Attach: gh project field-create --issue-field-id surfaces an existing org/repo issue field on a project as a column (createProjectV2IssueField). Local input structs supply the issue-field GraphQL types the vendored githubv4 lacks.
| Clear bool | ||
| } | ||
|
|
||
| // UpdateIssueFieldValueInput is defined locally because the vendored githubv4 lacks the issue-field types. |
There was a problem hiding this comment.
Same comment as I left on your other PR. We should consider opening a PR against the package we are vendoring to support these field types so we don't have mis-alignment between field types supported in different tooling and to avoid creating a maintenance layer here
| $ gh issue create --parent 100 | ||
| $ gh issue create --parent https://github.com/cli/go-gh/issues/42 | ||
| $ gh issue create --blocked-by 200,201 --blocking 300 | ||
| $ gh issue create --field "Team" --value "Platform" |
There was a problem hiding this comment.
Can I create an issue with multiple Issue Field Values? Or can I only create it with a single Field populated then I need to update the Issue after creation?
There was a problem hiding this comment.
These flags could be registered as stringarrayvar types, allowing the flags to be repeated:
gh issue create --field "Team" --value "Platform" --field "Priority" --value "High"
We'd loop through the arrays and pair up fields with values, in order.
The problem with this design is that ordering matters, but it might be ok.
There was a problem hiding this comment.
The other alternative is something like --field="name-goes-here=value-goes-here"
| # Set a single-select issue field value by option ID | ||
| $ gh issue edit-field 23 --field-id <field-id> --single-select-option-id <option-id> | ||
|
|
||
| # Set a multi-select issue field value by option IDs | ||
| $ gh issue edit-field 23 --field-id <field-id> --multi-select-option-ids <id1>,<id2> | ||
|
|
||
| # Clear an issue field value | ||
| $ gh issue edit-field 23 --field-id <field-id> --clear |
There was a problem hiding this comment.
nit: I commented on this PR as well - the ergonomics of this CLI contract feels a bit clunky to me. Needing to know the data type of the Field I am passing and specifying different flags for multi-select vs single-select is a bit awkward as a user
Adds support for Projects v2 issue fields.
Issue field values live on the issue itself, like labels and assignees. So the split is:
gh project item-list --format json.gh issue edit-field <issue> --field-id <id>with one of--text,--number,--date,--single-select-option-id,--multi-select-option-ids, or--clear.gh project field-create --issue-field-id <id>attaches an existing org or repo issue field to a project as a column.gh project item-editis unchanged, since issue field values are not set on the project item.The GraphQL input structs are defined locally because the vendored githubv4 does not have the issue field types yet.
Draft for now. Holding until issue fields are GA in the public schema.