linear-cli icon indicating copy to clipboard operation
linear-cli copied to clipboard

team list: add --json output

Open lakardion opened this issue 2 months ago • 2 comments

Problem

I look up teams programmatically in a script. linear team list prints only a fixed-width table, so the script must scrape it:

KEY     NAME                            CYCLES UPDATED        ID
ENG     Engineering                     Yes    27 minutes ago 11111111-1111-1111-1111-111111111111
SUP     Support - Front Line - Team     Yes    27 minutes ago 22222222-2222-2222-2222-222222222222

A name-to-key lookup needs the key, because team states and label list --team both reject a team name. team list is the only command that maps the two, and there is no team view.

team list is also the only list command without JSON: team states, label list, project list, milestone list and issue query all support -j, and document list supports --json.

Proposed change

Add -j, --json to linear team list, in the same shape as the other list commands:

{
  "nodes": [
    {
      "id": "11111111-1111-1111-1111-111111111111",
      "key": "ENG",
      "name": "Engineering",
      "cyclesEnabled": true,
      "updatedAt": "2026-09-03T13:00:00.000Z"
    }
  ],
  "pageInfo": { "hasNextPage": false, "endCursor": null }
}

Alternatives considered

No response

lakardion avatar Sep 03 '26 15:09 lakardion

makes sense! i'll put the bots on it. see what other commands are missing --json as well.

schpet avatar Sep 03 '26 19:09 schpet

In the meantime, linear api is a good option for scripting this. It takes a raw GraphQL query and prints the response as JSON:

linear api --paginate 'query { teams(first: 100) { nodes { id key name cyclesEnabled updatedAt } pageInfo { hasNextPage endCursor } } }'

With --paginate it walks every page and prints one JSON array of team nodes. Drop --paginate to get the raw response with nodes and pageInfo as-is.

schpetbot avatar Sep 03 '26 20:09 schpetbot