Skip to content

Commit 01189d6

Browse files
committed
Polish README with cleaner structure and commands table
1 parent 4c076e2 commit 01189d6

1 file changed

Lines changed: 74 additions & 155 deletions

File tree

README.md

Lines changed: 74 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -2,221 +2,145 @@
22

33
Command-line interface for managing OpenWorkers deployments.
44

5-
## Installation
5+
## Quick Start
66

77
```bash
8+
# Install
89
cargo install --path .
9-
```
10-
11-
## Configuration
12-
13-
The CLI uses aliases to connect to different backends. Config is stored in `~/.openworkers/config.json`.
14-
15-
### Alias Types
1610

17-
- **API**: Connect via REST API (hosted or self-hosted)
18-
- **DB**: Direct PostgreSQL connection (for infra/migrations)
19-
20-
### Managing Aliases
21-
22-
```bash
23-
# Add API alias
24-
ow alias set prod --api https://dash.openworkers.com/api/v1 --token <token>
25-
ow alias set dev --api http://localhost:7000 --token <token>
26-
27-
# Add DB alias (for infrastructure operations)
28-
ow alias set infra --db postgres://user:pass@host/db
29-
30-
# List aliases
31-
ow alias list
11+
# Login (opens browser)
12+
ow login
3213

33-
# Set default
34-
ow alias set-default prod
14+
# Create and deploy a worker
15+
ow workers create my-api
16+
ow workers deploy my-api worker.ts
3517

36-
# Remove alias
37-
ow alias rm old-alias
18+
# Your worker is live at https://my-api.workers.rocks
3819
```
3920

40-
### Default Alias
41-
42-
On first run, a `default` alias pointing to `https://dash.openworkers.com/api/v1` is created as default.
43-
44-
## Command Shortcuts
45-
46-
Resources:
47-
48-
| Command | Short |
49-
| ----------- | ----- |
50-
| `workers` | `w` |
51-
| `env` | `e` |
52-
| `storage` | `s` |
53-
| `kv` | `k` |
54-
| `databases` | `d` |
55-
56-
Operations:
57-
58-
| Command | Short |
59-
| -------- | ----- |
60-
| `list` | `ls` |
61-
| `delete` | `rm` |
62-
6321
## Commands
6422

65-
### Login
23+
| Command | Short | Description |
24+
| ----------- | ----- | ------------------------------ |
25+
| `workers` | `w` | Create, deploy, manage workers |
26+
| `env` | `e` | Environment variables/secrets |
27+
| `storage` | `s` | S3/R2 storage configurations |
28+
| `kv` | `k` | Key-value namespaces |
29+
| `databases` | `d` | SQL database bindings |
30+
| `alias` | | Backend connection aliases |
31+
| `login` | | Authenticate with API |
32+
| `migrate` | | Database schema migrations |
6633

67-
```bash
68-
# Set token on default alias
69-
ow login
70-
71-
# Set token on specific alias
72-
ow dev login
73-
```
34+
Common operations: `list` (`ls`), `get`, `create`, `delete` (`rm`)
7435

75-
### Workers
36+
## Workers
7637

7738
```bash
78-
# List workers
7939
ow workers list
80-
ow workers ls
81-
82-
# Create a worker
83-
ow workers create my-api -d "My API worker"
84-
ow workers create my-api --language javascript
85-
86-
# Get worker details
40+
ow workers create my-api -d "REST API"
8741
ow workers get my-api
88-
89-
# Deploy code to a worker
90-
ow workers deploy my-api ./src/index.ts
91-
ow workers deploy my-api ./src/index.ts -m "Fix bug"
92-
93-
# Delete a worker
42+
ow workers deploy my-api ./worker.ts -m "Initial deploy"
43+
ow workers upload my-app ./dist # Upload folder with assets
44+
ow workers link my-api --env prod # Link environment
9445
ow workers delete my-api
95-
ow workers rm my-api
9646
```
9747

9848
Supported file types: `.js`, `.ts`, `.wasm`
9949

100-
### Environments
50+
## Environments
10151

102-
Manage environment variables and secrets.
52+
Manage variables, secrets, and resource bindings.
10353

10454
```bash
105-
# List environments
10655
ow env list
56+
ow env create prod -d "Production"
57+
ow env get prod
10758

108-
# Get environment details
109-
ow env get production
110-
111-
# Create an environment
112-
ow env create production -d "Production environment"
113-
114-
# Set a variable
115-
ow env set production API_URL "https://api.example.com"
59+
# Variables and secrets
60+
ow env set prod API_URL "https://api.example.com"
61+
ow env set prod API_KEY "secret" --secret
62+
ow env unset prod OLD_VAR
11663

117-
# Set a secret (value will be masked)
118-
ow env set production API_KEY "secret-key" --secret
64+
# Bind resources
65+
ow env bind prod CACHE my-kv --type kv
66+
ow env bind prod DB my-db --type database
67+
ow env bind prod ASSETS my-storage --type assets
11968

120-
# Remove a variable
121-
ow env unset production API_URL
122-
123-
# Delete an environment
124-
ow env delete production
69+
ow env delete old-env
12570
```
12671

127-
### Storage
72+
## Storage
12873

129-
Manage S3/R2 storage configurations.
74+
S3-compatible storage (R2, MinIO, AWS S3).
13075

13176
```bash
132-
# List storage configs
13377
ow storage list
134-
135-
# Get storage details
136-
ow storage get my-storage
137-
138-
# Create platform storage (shared R2)
13978
ow storage create my-storage
140-
141-
# Create S3 storage
14279
ow storage create my-s3 --provider s3 \
14380
--bucket my-bucket \
144-
--access-key-id AKIAXXXXXXXX \
145-
--secret-access-key xxxxx \
146-
--endpoint https://s3.amazonaws.com
147-
148-
# Delete storage
81+
--endpoint https://xxx.r2.cloudflarestorage.com \
82+
--access-key-id AKIA... \
83+
--secret-access-key ...
14984
ow storage delete my-storage
15085
```
15186

152-
### KV
87+
## KV
15388

154-
Manage key-value namespaces.
89+
Key-value namespaces for caching and sessions.
15590

15691
```bash
157-
# List KV namespaces
15892
ow kv list
159-
160-
# Get KV details
161-
ow kv get my-kv
162-
163-
# Create KV namespace
164-
ow kv create my-kv -d "Cache storage"
165-
166-
# Delete KV namespace
167-
ow kv delete my-kv
93+
ow kv create cache -d "API cache"
94+
ow kv get cache
95+
ow kv delete cache
16896
```
16997

170-
### Databases
98+
## Databases
17199

172-
Manage database bindings.
100+
SQL database bindings.
173101

174102
```bash
175-
# List databases
176103
ow databases list
177-
178-
# Get database details
179-
ow databases get my-db
180-
181-
# Create platform database (shared)
182104
ow databases create my-db
183-
184-
# Create Postgres binding
185105
ow databases create my-pg --provider postgres \
186106
--connection-string "postgres://user:pass@host/db"
187-
188-
# Delete database
189107
ow databases delete my-db
190108
```
191109

192-
### Migrations
110+
## Aliases
193111

194-
Database schema migrations (requires `db` type alias).
112+
The CLI supports multiple backends via aliases. Config is stored in `~/.openworkers/config.json`.
195113

196114
```bash
197-
# Check migration status
198-
ow local migrate status
115+
# API backend (hosted or self-hosted)
116+
ow alias set prod --api https://dash.openworkers.com
117+
ow alias set dev --api http://localhost:8080 --insecure
199118

200-
# Run pending migrations
201-
ow local migrate run
119+
# DB backend (direct PostgreSQL, for migrations)
120+
ow alias set local --db postgres://user:pass@localhost/ow --user admin@example.com
202121

203-
# Baseline existing database (mark all migrations as applied)
204-
ow local migrate baseline
122+
# Manage aliases
123+
ow alias list
124+
ow alias set-default prod
125+
ow alias rm old-alias
205126
```
206127

207-
### Using Aliases
128+
Use an alias by prefixing commands:
208129

209130
```bash
210-
# Use default alias
211-
ow workers list
131+
ow workers list # Uses default alias
132+
ow prod workers list # Uses 'prod' alias
133+
ow local migrate run # Uses 'local' alias
134+
```
135+
136+
## Migrations
212137

213-
# Use specific alias as first argument
214-
ow prod workers list
215-
ow dev workers get my-api
216-
ow local migrate run
138+
Database schema migrations (requires DB alias).
217139

218-
# Or use --alias flag
219-
ow --alias prod workers list
140+
```bash
141+
ow local migrate status # Show pending migrations
142+
ow local migrate run # Apply migrations
143+
ow local migrate baseline # Mark all as applied (existing DB)
220144
```
221145

222146
## Config File
@@ -231,14 +155,9 @@ ow --alias prod workers list
231155
"url": "https://dash.openworkers.com/api/v1",
232156
"token": "ow_xxx"
233157
},
234-
"dev": {
235-
"type": "api",
236-
"url": "http://localhost:7000",
237-
"token": "ow_xxx"
238-
},
239158
"local": {
240159
"type": "db",
241-
"database_url": "postgres://user:pass@host/db",
160+
"database_url": "postgres://localhost/openworkers",
242161
"user": "admin@example.com"
243162
}
244163
}
@@ -250,5 +169,5 @@ ow --alias prod workers list
250169
```bash
251170
cargo build
252171
cargo run -- workers list
253-
cargo run -- dev workers list
172+
cargo run -- local migrate status
254173
```

0 commit comments

Comments
 (0)