Commit 7e681bf
feat: Make CLI output machine-readable and pipeable (#588)
Replace ad hoc console.log calls with an injectable Output so the CLI has
one place that decides what goes where, and so output can be asserted in
tests with an in-memory implementation.
- Only command results go to stdout: prompts, spinners, progress, and
other information are written to stderr.
- Add --json to read request params from stdin and write the response as
JSON. The JSON format is used automatically when stdout is not a
terminal, and --no-json opts out.
- Support unix pipes end to end: params may be piped or redirected in,
and the response piped or redirected out.
- Trim responses to the response key and pagination, using the response
key from the API blueprint.
- Exit non-zero on a failed request or an error.
Claude-Session: https://claude.ai/code/session_01NKsb8oTieozDEGJtiwWqBo
Co-authored-by: Claude <noreply@anthropic.com>1 parent e31c80c commit 7e681bf
33 files changed
Lines changed: 1101 additions & 151 deletions
File tree
- src
- bin
- lib
- output
- util
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
100 | 158 | | |
101 | 159 | | |
102 | 160 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments