Skip to content

Commit 960b063

Browse files
committed
feat: Add wait flag and polling mechanism for build completion
1 parent 3cbc3e4 commit 960b063

File tree

9 files changed

+874
-9
lines changed

9 files changed

+874
-9
lines changed

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Stainless API CLI
2+
3+
A command-line interface for interacting with the Stainless API to manage projects, builds, and SDK generation.
4+
5+
## Installation
6+
7+
```bash
8+
go install github.com/stainless-api/stainless-api-cli@latest
9+
```
10+
11+
## Authentication
12+
13+
Before using the CLI, you need to authenticate with the Stainless API.
14+
15+
```bash
16+
# Log in using OAuth device flow
17+
stainless-api-cli auth login
18+
19+
# Check authentication status
20+
stainless-api-cli auth status
21+
22+
# Log out and remove saved credentials
23+
stainless-api-cli auth logout
24+
```
25+
26+
You can also authenticate by setting the `STAINLESS_API_KEY` environment variable, which takes precedence over saved credentials.
27+
28+
## Projects
29+
30+
Manage your Stainless projects.
31+
32+
```bash
33+
# Retrieve a project
34+
stainless-api-cli projects retrieve --project-name <project-name>
35+
36+
# Update a project
37+
stainless-api-cli projects update --project-name <project-name> --display-name "New Project Name"
38+
```
39+
40+
### Project Branches
41+
42+
```bash
43+
# Create a new branch
44+
stainless-api-cli projects:branches create --project <project-name> --branch <branch-name> --branch-from main
45+
46+
# Retrieve a branch
47+
stainless-api-cli projects:branches retrieve --project <project-name> --branch <branch-name>
48+
```
49+
50+
### Project Configs
51+
52+
```bash
53+
# Retrieve project configuration
54+
stainless-api-cli projects:configs retrieve --project <project-name> --branch <branch-name>
55+
56+
# Guess project configuration based on OpenAPI spec
57+
stainless-api-cli projects:configs guess --project <project-name> --spec <path-to-spec>
58+
```
59+
60+
## Builds
61+
62+
Create and manage builds for your projects.
63+
64+
```bash
65+
# Create a new build
66+
stainless-api-cli builds create --project <project-name> --revision <revision> --openapi-spec <path-to-spec> --stainless-config <path-to-config>
67+
68+
# Create a build and wait for completion
69+
stainless-api-cli builds create --project <project-name> --revision <revision> --openapi-spec <path-to-spec> --wait
70+
71+
# Create a build, wait for completion, and pull outputs
72+
stainless-api-cli builds create --project <project-name> --revision <revision> --openapi-spec <path-to-spec> --wait --pull
73+
74+
# Retrieve a build
75+
stainless-api-cli builds retrieve --build-id <build-id>
76+
77+
# List builds for a project
78+
stainless-api-cli builds list --project <project-name> --branch <branch-name>
79+
```
80+
81+
## Build Target Outputs
82+
83+
Retrieve and pull build target outputs.
84+
85+
```bash
86+
# Retrieve build target output
87+
stainless-api-cli build_target_outputs retrieve --build-id <build-id> --target <target> --type <type> --output <output>
88+
89+
# Pull build target output
90+
stainless-api-cli build_target_outputs pull --build-id <build-id> --target <target> --type <type> --output <output>
91+
```
92+
93+
## Environment Variables
94+
95+
- `STAINLESS_API_KEY`: API key for authentication (takes precedence over saved credentials)
96+
- `NO_COLOR`: Disable colored output
97+
- `FORCE_COLOR`: Force colored output (`1` to enable, `0` to disable)
98+
99+
## Examples
100+
101+
```bash
102+
# Generate a TypeScript SDK for your API
103+
stainless-api-cli builds create --project my-project --branch main --openapi-spec ./openapi.yml --wait --pull --targets typescript
104+
105+
# Generate multiple SDKs at once
106+
stainless-api-cli builds create --project my-project --branch main --openapi-spec ./openapi.yml --wait --pull --targets typescript,python,go
107+
```
108+
109+
## Shell Completion
110+
111+
The CLI supports shell completion. To enable it:
112+
113+
```bash
114+
# For bash
115+
stainless-api-cli completion bash > /etc/bash_completion.d/stainless-api-cli
116+
117+
# For zsh
118+
stainless-api-cli completion zsh > "${fpath[1]}/_stainless-api-cli"
119+
120+
# For fish
121+
stainless-api-cli completion fish > ~/.config/fish/completions/stainless-api-cli.fish
122+
```
123+
124+
## Available SDK Targets
125+
126+
The Stainless API CLI can generate SDKs for multiple languages:
127+
128+
- `typescript` - TypeScript SDK
129+
- `node` - Node.js SDK
130+
- `python` - Python SDK
131+
- `go` - Go SDK
132+
- `ruby` - Ruby SDK
133+
- `java` - Java SDK
134+
- `kotlin` - Kotlin SDK
135+
- `cli` - Command-line interface
136+
- `terraform` - Terraform provider

0 commit comments

Comments
 (0)