@superflag-sh/cli 0.1.3 → 0.1.4
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 +212 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# @superflag-sh/cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@superflag-sh/cli)
|
|
4
|
+
|
|
5
|
+
Command-line interface for managing [Superflag](https://superflag.sh) feature flags and remote config.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Install globally
|
|
11
|
+
npm install -g @superflag-sh/cli
|
|
12
|
+
|
|
13
|
+
# Authenticate
|
|
14
|
+
superflag login
|
|
15
|
+
|
|
16
|
+
# Set your default app and environment
|
|
17
|
+
superflag use myapp production
|
|
18
|
+
|
|
19
|
+
# Get and set flags
|
|
20
|
+
superflag get dark-mode
|
|
21
|
+
superflag set dark-mode true
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Authentication
|
|
25
|
+
|
|
26
|
+
The CLI uses browser-based OAuth authentication:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
superflag login # Opens browser to authenticate
|
|
30
|
+
superflag whoami # Show current user
|
|
31
|
+
superflag logout # Clear credentials
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Credentials are stored in `~/.superflag/credentials.json`.
|
|
35
|
+
|
|
36
|
+
## Context System
|
|
37
|
+
|
|
38
|
+
Instead of passing `--app` and `--env` with every command, set a default context:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
superflag use myapp staging
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This saves your context to `~/.superflag/context.json`. Quick commands like `get`, `set`, and `config` will use this context automatically.
|
|
45
|
+
|
|
46
|
+
You can override context for a single command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
superflag get feature-x --app other-app --env prod
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Check your current context with:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
superflag status
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Commands
|
|
59
|
+
|
|
60
|
+
### Quick Commands
|
|
61
|
+
|
|
62
|
+
These commands use your saved context for fast flag operations:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
superflag use <app> <env> # Set default app/env context
|
|
66
|
+
superflag get <key> # Get a flag value
|
|
67
|
+
superflag set <key> <value> # Set a flag value
|
|
68
|
+
superflag config # Dump full config as JSON
|
|
69
|
+
superflag status # Show auth and context status
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Auth Commands
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
superflag login # Authenticate via browser
|
|
76
|
+
superflag logout # Clear credentials and context
|
|
77
|
+
superflag whoami # Show current user email
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Apps
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
superflag apps list # List all your apps
|
|
84
|
+
superflag apps create <name> # Create a new app
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Environments
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
superflag envs list --app <name> # List environments for an app
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Flags
|
|
94
|
+
|
|
95
|
+
**List and manage flags:**
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
superflag flags list --app <name> --env <slug>
|
|
99
|
+
superflag flags create --app <name> --env <slug> --key <key> --type <type> --value <value>
|
|
100
|
+
superflag flags set --app <name> --env <slug> --key <key> --value <value>
|
|
101
|
+
superflag flags toggle --app <name> --env <slug> --key <key>
|
|
102
|
+
superflag flags delete --app <name> --env <slug> --key <key>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Idempotent upsert (uses context):**
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
superflag flags upsert --key new-feature --type bool --value true
|
|
109
|
+
superflag flags upsert --key new-feature --type bool --value true --client # Enable for client SDKs
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Flag types: `bool`, `string`, `number`, `json`
|
|
113
|
+
|
|
114
|
+
**Gradual rollout:**
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
superflag flags rollout --key feature-x --percentage 25 # Roll out to 25%
|
|
118
|
+
superflag flags rollout --key feature-x --percentage 100 # Full rollout
|
|
119
|
+
superflag flags rollout --key feature-x --remove # Remove rollout
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**A/B test variants:**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Format: --variant "value:weight:name"
|
|
126
|
+
superflag flags variants --key button-color \
|
|
127
|
+
--variant "blue:50:control" \
|
|
128
|
+
--variant "green:30:variant-a" \
|
|
129
|
+
--variant "red:20:variant-b"
|
|
130
|
+
|
|
131
|
+
superflag flags variants --key button-color --remove # Remove variants
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Weights must sum to 100. Names are optional.
|
|
135
|
+
|
|
136
|
+
**Bulk operations:**
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# From file
|
|
140
|
+
superflag flags bulk-set --file flags.json
|
|
141
|
+
|
|
142
|
+
# From stdin
|
|
143
|
+
echo '{"feature-a": true, "feature-b": "new-value"}' | superflag flags bulk-set
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
JSON format: `{"flag-key": value, ...}`
|
|
147
|
+
|
|
148
|
+
### Keys
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
superflag keys list --app <name> --env <slug>
|
|
152
|
+
superflag keys create --app <name> --env <slug> --type <sdk|pub>
|
|
153
|
+
superflag keys revoke <key-id>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Key types:
|
|
157
|
+
- `sdk` - Server-side SDK key (full config access)
|
|
158
|
+
- `pub` - Client-side public key (filtered to client-enabled flags only)
|
|
159
|
+
|
|
160
|
+
## Global Options
|
|
161
|
+
|
|
162
|
+
| Option | Description |
|
|
163
|
+
|--------|-------------|
|
|
164
|
+
| `--json` | Output as JSON |
|
|
165
|
+
| `--quiet`, `-q` | Suppress non-essential output |
|
|
166
|
+
| `--app <name>` | Override app context for this command |
|
|
167
|
+
| `--env <slug>` | Override env context for this command |
|
|
168
|
+
| `--help`, `-h` | Show help |
|
|
169
|
+
| `--version`, `-v` | Show version |
|
|
170
|
+
|
|
171
|
+
## Environment Variables
|
|
172
|
+
|
|
173
|
+
| Variable | Default | Description |
|
|
174
|
+
|----------|---------|-------------|
|
|
175
|
+
| `SUPERFLAG_API_URL` | `https://superflag.sh/api/v1` | API endpoint |
|
|
176
|
+
| `SUPERFLAG_AUTH_URL` | `https://superflag.sh/cli-auth` | Auth endpoint |
|
|
177
|
+
|
|
178
|
+
## Exit Codes
|
|
179
|
+
|
|
180
|
+
| Code | Meaning |
|
|
181
|
+
|------|---------|
|
|
182
|
+
| 0 | Success |
|
|
183
|
+
| 1 | Generic error |
|
|
184
|
+
| 2 | Authentication or context required |
|
|
185
|
+
| 3 | Resource not found |
|
|
186
|
+
|
|
187
|
+
## Development
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Clone and install
|
|
191
|
+
git clone <repo>
|
|
192
|
+
cd superflag-cli
|
|
193
|
+
bun install
|
|
194
|
+
|
|
195
|
+
# Run in development
|
|
196
|
+
bun run dev <command>
|
|
197
|
+
bun run dev use myapp staging
|
|
198
|
+
bun run dev get feature-x
|
|
199
|
+
|
|
200
|
+
# Build
|
|
201
|
+
bun run build
|
|
202
|
+
|
|
203
|
+
# Type check
|
|
204
|
+
bun run typecheck
|
|
205
|
+
|
|
206
|
+
# Run tests
|
|
207
|
+
bun test
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## License
|
|
211
|
+
|
|
212
|
+
MIT
|