|
1 | | -# Stainless API CLI |
| 1 | +# Stainless V0 CLI |
2 | 2 |
|
3 | | -A command-line interface for interacting with the Stainless API to manage projects, builds, and SDK generation. |
| 3 | +The official CLI for the Stainless V0 REST API. |
4 | 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 |
| 5 | +It is generated with [Stainless](https://www.stainless.com/). |
51 | 6 |
|
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 |
| 7 | +## Installation |
82 | 8 |
|
83 | | -Retrieve and pull build target outputs. |
| 9 | +### Installing with Go |
84 | 10 |
|
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> |
| 11 | +<!-- x-release-please-start-version --> |
88 | 12 |
|
89 | | -# Pull build target output |
90 | | -stainless-api-cli build_target_outputs pull --build-id <build-id> --target <target> --type <type> --output <output> |
| 13 | +```sh |
| 14 | +go install 'github.com/stainless-api/stainless-api-cli' |
91 | 15 | ``` |
92 | 16 |
|
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) |
| 17 | +<!-- x-release-please-end --> |
98 | 18 |
|
99 | | -## Examples |
| 19 | +## Usage |
100 | 20 |
|
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 |
| 21 | +The CLI follows a resource-based command structure: |
104 | 22 |
|
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 |
| 23 | +```sh |
| 24 | +stainless-api-cli [resource] [command] [flags] |
107 | 25 | ``` |
108 | 26 |
|
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 |
| 27 | +```sh |
| 28 | +stainless-api-cli builds create \ |
| 29 | + --project project \ |
| 30 | + --revision string |
122 | 31 | ``` |
123 | 32 |
|
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 |
| 33 | +For details about specific commands, use the `--help` flag. |
0 commit comments