View & edit custom fields associated with an item in a project
benjiallen opened this issue · 5 comments
It would be awesome if you could view & edit the custom fields associated with a project & item using the command line.
The methods I expected to work
Method 1 - view the items in the project
gh projects item-list 9029 --org github
I see a list of items but I don't see custom fields.
Method 2 - view the issue to inspect custom fields
gh issue view 45 --repo github/accessibility-playbook
I get the issue data but I don't get the project association nor the custom fields associated with the issue.
Editing
There is an edit flow within an issue using:
gh issue edit 45 --repo github/accessibility-playbook
It would be great if you could edit the custom fields associated with an item in a similar way. I think the main challenge with this interaction is that you would have to target the custom data associated with a specific project. It would likely make more sense to have the feature associated with gh projects
. For example:
gh projects edit 1 --org github --<custom_field_name> "New value"
@benjiallen thanks for the feedback!
For method 1, you're correct that the fields are static. This is partially due to the column layout, and not wanting to exceed reasonable terminal widths, and partly because it's challenging to do with the way the APIs return data. That being said, I intend to release JSON support in the upcoming release, which will show all the custom fields and much of their data. You can then convert the JSON to a column format if you prefer!
For method 2, would you mind opening an issue in https://github.com/cli/cli as they are the owners of the issue
subcommand?
For editing, there's currently no api for editing fields https://docs.github.com/en/graphql/reference/mutations so unfortunately there's nothing for the extension to invoke.
@mntlty thanks for getting back to me. You're doing great work.
For method 1, you're correct that the fields are static. This is partially due to the column layout, and not wanting to exceed reasonable terminal widths, and partly because it's challenging to do with the way the APIs return data. That being said, I intend to release JSON support in the upcoming release, which will show all the custom fields and much of their data. You can then convert the JSON to a column format if you prefer!
JSON support would be super cool. I think the really nice thing about the --json
option is that you can pass in a comma separated list of fields you want. Perhaps that is a good way of keeping custom fields output manageable. I'd love to see control over what fields appear in the JSON output. Something like:
gh projects item-list 9029 --org github --json "id,title,custom_field_1,custom_field_2"
I wonder if a similar approach would help control output to the terminal and reduce your concerns around terminal width. For example, maybe a --columns
option would be useful to control the data fields that are displayed. You could keep your current approach as the reasonable default and then let the user decide if they want to customize the output with --columns
. Something like:
gh projects item-list 9029 --org github --columns "id,title,custom_field_1,custom_field_2"
For method 2, would you mind opening an issue in https://github.com/cli/cli as they are the owners of the issue subcommand?
Yep, will do.
For editing, there's currently no api for editing fields https://docs.github.com/en/graphql/reference/mutations so unfortunately there's nothing for the extension to invoke.
What does this endpoint do? https://docs.github.com/en/graphql/reference/mutations#updateprojectv2itemfieldvalue
Does that change the value of the field or just the type of the field (e.g., text to single select)?
For method 2, would you mind opening an issue in https://github.com/cli/cli as they are the owners of the issue subcommand?
Added a comment to this existing issue: Add Projects custom field information to issue list output
thanks! I'm going to close this issue, please reopen if I've missed anything
@benjiallen my apologies, I missed your first comment and only saw the second one 😬 responses below!
JSON support would be super cool.
I agree! JSON support was introduced in this release, however I made some changes to the output format, and suggest using v2.0.0 of this extension, which also has support for limits for list
, item-list
and field-list
commands.
All of the commands support a --format=json
directive, which works similarly to the --json
in the CLI. The difference here is that fields are dynamic, so it's up to the user to do filtering with jq
or a similar utility. As an example, you can run
gh projects list --user mntlty --format=json
to get all of the public projects.
If you have any suggestions for how to surface this capability better, please let me know!
I wonder if a similar approach would help control output to the terminal and reduce your concerns around terminal width.
I hear the suggestion of letting users configure their terminal width - currently I'm relying on https://pkg.go.dev/github.com/cli/go-gh/pkg/term which has some configuration options, and should be the same as are available in the gh
CLI.
What does this endpoint do? https://docs.github.com/en/graphql/reference/mutations#updateprojectv2itemfieldvalue
From the docs: This mutation updates the value of a field for an item in a Project.
In other words, you can update the text value for a field, but does not allow you to modify the field itself, say to change the options for a single select field.
@mntlty thanks for getting back to me. You're doing great work.
I appreciate your appreciation, thank you 💖