0

I use gh command to list and print all issues to a CSV file, but I can't get the all assignees also.

The complete command I use:

gh issue list --limit 1000 --state all | tr '\t' ',' > issues.csv
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
acun
  • 57
  • 4

1 Answers1

1

Since the default output contains comma-separated labels and one issue can have more than one label, your approach (converting all tabs to commas) can result in a malformed CSV output. To fix just that, you could use a CSV-aware tool such as xsv:

gh issue list --state all | xsv fmt -d '\t' > issues.csv

This properly quotes fields containing a comma.

Now, to get assignees as well, you can use the --json flag that lets you select which fields you want in the response, and --jq to massage the JSON response into CSV format.

For example, to get number, state, title, timestamp of the last update, labels, and assignees:

gh issue list --state all \
    --json number,state,title,labels,updatedAt,assignees \
    --jq '
        map([
            .number,
            .state,
            .title,
            .updatedAt,
            (.labels | map(.name) | join(",")),
            (.assignees | map(.login) | join(","))
        ])[]
        | @csv
    '
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116