clx-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # clx
2
+
3
+ CLI API Client Generator - Turn any OpenAPI spec into a command-line tool.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Install an API from the registry
9
+ clx install stripe
10
+
11
+ # Use it directly
12
+ stripe customers list --limit=10
13
+ stripe customers get cus_xxx --output=table
14
+ stripe customers create --email=user@example.com --name="John Doe"
15
+
16
+ # Configure authentication
17
+ stripe auth login
18
+ ```
19
+
20
+ ## Installation
21
+
22
+ ### npm (recommended)
23
+
24
+ ```bash
25
+ npm install -g clx-cli
26
+ ```
27
+
28
+ ### From Source (requires Bun)
29
+
30
+ ```bash
31
+ git clone https://github.com/golergka/clx.git
32
+ cd clx
33
+ bun install
34
+ bun run compile
35
+ ```
36
+
37
+ ### Binary Releases
38
+
39
+ See [Releases](https://github.com/golergka/clx/releases) for pre-built binaries.
40
+
41
+ ## Features
42
+
43
+ - **Zero code generation** - Parses OpenAPI specs at runtime
44
+ - **Busybox pattern** - Single binary, multiple symlinks (e.g., `stripe`, `github`)
45
+ - **Multi-auth support** - API keys, Bearer tokens, Basic auth, OAuth 2.0
46
+ - **Auth profiles** - Multiple credentials per API (`--profile prod`)
47
+ - **Agent-friendly** - Compact help, JSON output, semantic exit codes
48
+ - **Shell completions** - bash, zsh, fish
49
+
50
+ ## Usage
51
+
52
+ ### Package Management
53
+
54
+ ```bash
55
+ # Search available APIs
56
+ clx search stripe
57
+
58
+ # Install from registry
59
+ clx install stripe
60
+
61
+ # Install from URL
62
+ clx install https://api.example.com/openapi.yaml --name myapi
63
+
64
+ # Install from local file
65
+ clx add ./spec.yaml --name myapi
66
+
67
+ # List installed APIs
68
+ clx list
69
+
70
+ # Update an API
71
+ clx update stripe
72
+
73
+ # Update all APIs
74
+ clx update --all
75
+
76
+ # Remove an API
77
+ clx remove stripe
78
+ ```
79
+
80
+ ### Authentication
81
+
82
+ ```bash
83
+ # Configure auth (interactive)
84
+ stripe auth login
85
+
86
+ # Use named profiles
87
+ stripe auth login --profile prod
88
+ stripe auth switch prod
89
+ stripe auth list
90
+
91
+ # Check status
92
+ stripe auth status
93
+
94
+ # Logout
95
+ stripe auth logout
96
+ ```
97
+
98
+ ### Making Requests
99
+
100
+ ```bash
101
+ # GET with query params
102
+ stripe customers list --limit=10 --starting_after=cus_xxx
103
+
104
+ # GET with path params
105
+ stripe customers get --customer=cus_xxx
106
+
107
+ # POST with body (from flags)
108
+ stripe customers create --email=user@example.com --name="John Doe"
109
+
110
+ # POST with body (from stdin)
111
+ echo '{"email": "user@example.com"}' | stripe customers create
112
+
113
+ # PUT/PATCH/DELETE
114
+ stripe customers update --customer=cus_xxx --name="Jane Doe"
115
+ stripe customers delete --customer=cus_xxx
116
+ ```
117
+
118
+ ### Output Formatting
119
+
120
+ ```bash
121
+ # Default JSON output
122
+ stripe customers list
123
+
124
+ # Pretty-printed JSON (default)
125
+ stripe customers list --output=json
126
+
127
+ # Compact JSON
128
+ stripe customers list --compact
129
+
130
+ # Table format
131
+ stripe customers list --output=table
132
+
133
+ # Extract specific field
134
+ stripe customers get --customer=cus_xxx --field=email
135
+
136
+ # Combine with jq
137
+ stripe customers list | jq '.data[].email'
138
+ ```
139
+
140
+ ### Debugging
141
+
142
+ ```bash
143
+ # Show curl equivalent (dry run)
144
+ stripe customers list --dry-run
145
+
146
+ # Verbose output (request/response details)
147
+ stripe customers list --verbose
148
+
149
+ # Diagnose setup issues
150
+ clx doctor
151
+ ```
152
+
153
+ ## Configuration
154
+
155
+ Configuration is stored in `~/.config/clx/` (or `$XDG_CONFIG_HOME/clx/`):
156
+
157
+ ```
158
+ ~/.config/clx/
159
+ ├── specs/ # Downloaded OpenAPI specs
160
+ │ ├── stripe.yaml
161
+ │ └── github.yaml
162
+ └── auth/ # Auth credentials (mode 700)
163
+ ├── stripe.json
164
+ └── github.json
165
+ ```
166
+
167
+ ### Environment Variables
168
+
169
+ - `CLX_CONFIG_DIR` - Override config directory
170
+ - `CLX_BIN_DIR` - Override symlink directory (default: `/usr/local/bin`)
171
+
172
+ ## Shell Completions
173
+
174
+ ```bash
175
+ # Bash
176
+ eval "$(clx completion bash)"
177
+
178
+ # Zsh
179
+ eval "$(clx completion zsh)"
180
+
181
+ # Fish
182
+ clx completion fish | source
183
+ ```
184
+
185
+ Add to your shell's rc file for persistence.
186
+
187
+ ## Available APIs
188
+
189
+ ```bash
190
+ clx search
191
+ ```
192
+
193
+ Current registry includes:
194
+ - Stripe
195
+ - GitHub
196
+ - OpenAI
197
+ - Anthropic (unofficial spec)
198
+ - Slack
199
+ - Twilio
200
+ - Discord
201
+ - Petstore (demo)
202
+
203
+ ## Error Handling
204
+
205
+ clx uses semantic exit codes:
206
+
207
+ | Code | Meaning |
208
+ |------|---------|
209
+ | 0 | Success |
210
+ | 1 | General error |
211
+ | 2 | Usage error (bad arguments) |
212
+ | 3 | Configuration error |
213
+ | 4 | Authentication error |
214
+ | 5 | Network error |
215
+ | 6 | API error (4xx/5xx) |
216
+ | 7 | Spec parsing error |
217
+ | 8 | I/O error |
218
+
219
+ ## For AI Agents
220
+
221
+ clx is designed to be agent-friendly:
222
+
223
+ - Compact help output (< 50 tokens per command)
224
+ - Structured JSON responses
225
+ - Semantic exit codes for error handling
226
+ - `--dry-run` for safe exploration
227
+ - No interactive prompts in non-TTY mode
228
+ - Stdin piping for complex payloads
229
+
230
+ Example agent workflow:
231
+
232
+ ```bash
233
+ # Explore the API
234
+ stripe --help
235
+ stripe customers --help
236
+ stripe customers create --help
237
+
238
+ # Test with dry-run
239
+ stripe customers create --email=test@example.com --dry-run
240
+
241
+ # Execute
242
+ stripe customers create --email=test@example.com
243
+ ```
244
+
245
+ ## Development
246
+
247
+ ```bash
248
+ # Install dependencies
249
+ bun install
250
+
251
+ # Run in development
252
+ bun run src/index.ts --help
253
+ bun run src/index.ts stripe customers list
254
+
255
+ # Type check
256
+ bun run typecheck
257
+
258
+ # Build
259
+ bun run build
260
+ ```
261
+
262
+ ## License
263
+
264
+ MIT - see [LICENSE](LICENSE).
package/dist/clx ADDED
Binary file