mirror of
https://github.com/schpet/linear-cli.git
synced 2026-09-14 14:26:50 +08:00
3582fc5700
Adds a `linear api` subcommand for making raw GraphQL requests, mirroring [`gh api`](https://cli.github.com/manual/gh_api) conventions. ## Changes - Accepts a GraphQL query as a positional arg, from stdin with `-`, or via auto-detected piped input - `--variable key=value` for typed variable coercion (booleans, numbers, null, `@file` for file reads, `@-` for stdin) - `--variables-json '{"key": "value"}'` for passing all variables as a JSON object (merged with `--variable`, which takes precedence) - `--paginate` walks `pageInfo.endCursor` automatically and outputs concatenated `nodes` array - `--silent` suppresses response output while exit code still reflects errors - Pretty-prints JSON when stdout is a TTY, raw JSON otherwise for piping to `jq` - Exits with code 1 on HTTP errors (status >= 400) and GraphQL-level errors - Uses raw `fetch` so users see the exact server response including both `data` and `errors` fields ## Testing - Snapshot tests using `MockLinearServer` cover query resolution, variable handling (type coercion, `@file`, `--variables-json`, precedence), output modes, pagination (multi-page, single-page, non-connection), auth errors, and `--silent` behavior for both successful and HTTP error responses - Manual testing against live Linear API: cycles, workflow states, notifications (with `--paginate`), non-existent issue lookup, variable type mismatch errors, stdin piping ## Related - Closes #123