Skip to content

Commit b437261

Browse files
committed
fixes, local utility script
1 parent 3a6f442 commit b437261

5 files changed

Lines changed: 230 additions & 142 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/dist
33
/.release-work
44
/disc-signals.ndjson
5+
/.env.local
6+
/.env.prod

README.md

Lines changed: 138 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,154 @@
1-
# disc-cli
1+
# Disc CLI
22

3-
Native Rust CLI for Disc signal discovery and live signal consumption.
3+
Native Rust CLI for **Disc** – discover signals and consume live data streams.
44

5-
The current v1 scope is aligned with the live Disc signal stack:
5+
---
66

7-
- HTTP discovery via `api.disc.tech`
8-
- WebSocket subscriptions via `signals.disc.tech`
9-
- API-key authentication via `X-Disc-Api-Key`
10-
- MessagePack websocket protocol compatible with the current Disc signals services
11-
12-
## Build
7+
## Quick start (30 seconds)
138

149
```bash
15-
cargo build
16-
```
10+
brew install disctechnologies/tap/disc
1711

18-
Run directly during development:
12+
# set your API key once
13+
disc auth api-key set
1914

20-
```bash
21-
cargo run --bin disc -- --help
15+
# stream a signal
16+
disc signals passive subscribe <passive-signal-id> --format ndjson
2217
```
2318

24-
Use the thin local-stack wrapper:
19+
---
2520

26-
```bash
27-
./disc.sh auth whoami
28-
```
21+
## What it does
2922

30-
The wrapper pins local defaults:
23+
- 🔍 Discover passive and active signals
24+
- 📡 Subscribe to live signal streams (WebSocket)
25+
- 🔐 Authenticate via API key (`X-Disc-Api-Key`)
26+
- ⚡ Stream data to stdout (pipe-friendly)
3127

32-
- HTTP: `http://localhost:3001`
33-
- WS: `ws://localhost:8097`
34-
- client id: `disc-cli-local`
28+
Backed by:
29+
- HTTP: `api.disc.tech`
30+
- WS: `signals.disc.tech` (MessagePack protocol)
3531

36-
If `DISC_LOCAL_API_KEY` is set, the wrapper injects it automatically. If it is not set, it falls back to `DISC_API_KEY`, and otherwise uses whatever auth state the CLI resolves on its own.
32+
---
3733

38-
## Auth
34+
## Installation
3935

40-
Store an API key locally:
36+
### Homebrew (recommended)
4137

4238
```bash
43-
cargo run --bin disc -- auth api-key set
39+
brew tap disctech/tap
40+
brew install disc
4441
```
4542

46-
Or pass it per-command:
43+
Verify:
4744

4845
```bash
49-
DISC_API_KEY=... cargo run --bin disc -- auth whoami
46+
disc --version
5047
```
5148

52-
Validate the configured credential:
49+
---
50+
51+
## Authentication
52+
53+
Set your API key (stored locally):
5354

5455
```bash
55-
cargo run --bin disc -- auth whoami
56+
disc auth api-key set
5657
```
5758

58-
## Signal discovery
59-
60-
List passive signals:
59+
Or pass per command:
6160

6261
```bash
63-
cargo run --bin disc -- signals passive list
62+
DISC_API_KEY=... disc auth whoami
6463
```
6564

66-
Get one passive signal:
65+
Check current auth:
6766

6867
```bash
69-
cargo run --bin disc -- signals passive get <passive-signal-id>
68+
disc auth whoami
7069
```
7170

72-
List active signals for a passive signal:
71+
---
72+
73+
## Discover signals
74+
75+
### Passive signals
7376

7477
```bash
75-
cargo run --bin disc -- signals active list --for-passive <passive-signal-id>
78+
disc signals passive list
79+
disc signals passive get <passive-signal-id>
7680
```
7781

78-
Get one active signal:
82+
### Active signals
7983

8084
```bash
81-
cargo run --bin disc -- signals active get <active-signal-id>
85+
disc signals active list --for-passive <passive-signal-id>
86+
disc signals active get <active-signal-id>
8287
```
8388

84-
## Live streaming
89+
---
8590

86-
`subscribe` is the machine-oriented path:
91+
## Stream live data
8792

88-
- silently maintains the websocket subscription
89-
- forwards matched events to a destination
90-
- defaults to `ndjson`
93+
### Subscribe (machine-friendly)
9194

92-
`tail` is the human-oriented path:
95+
Streams events to stdout (best for piping):
9396

94-
- pretty-prints live events to the console
95-
- includes subscription lifecycle output by default
97+
```bash
98+
disc signals passive subscribe <passive-signal-id> --format ndjson
99+
```
100+
101+
Pipe to another process:
102+
103+
```bash
104+
disc signals passive subscribe <passive-signal-id> --format ndjson | jq
105+
```
96106

97-
Subscribe to one passive signal and forward to stdout:
107+
Write to file:
98108

99109
```bash
100-
cargo run --bin disc -- signals passive subscribe <passive-signal-id>
110+
disc signals passive subscribe <passive-signal-id> \
111+
--format ndjson \
112+
--destination ./output.ndjson
101113
```
102114

103-
Subscribe with backfill and append to a file:
115+
With backfill:
104116

105117
```bash
106-
cargo run --bin disc -- signals passive subscribe <passive-signal-id> \
118+
disc signals passive subscribe <passive-signal-id> \
107119
--backfill \
108120
--backfill-count 5 \
109-
--include-status \
110-
--format ndjson \
111-
--destination ./passive-signal.ndjson
121+
--format ndjson
112122
```
113123

114-
Tail one active signal in the console:
124+
---
125+
126+
### Tail (human-friendly)
127+
128+
Pretty console output:
115129

116130
```bash
117-
cargo run --bin disc -- signals active tail <active-signal-id> \
118-
--window-semantics ordinal \
119-
--format pretty
131+
disc signals active tail <active-signal-id> --format pretty
120132
```
121133

122-
Interactive subscription manager:
134+
---
135+
136+
### Interactive mode
123137

124138
```bash
125-
cargo run --bin disc -- signals subscribe
139+
disc signals subscribe
126140
```
127141

128-
That opens a persistent prompt where you can:
142+
- toggle passive signals
143+
- explore active signals
144+
- manage live subscriptions
145+
- stream to file
129146

130-
- toggle passive signal subscriptions
131-
- pick a passive signal and expand its active signals
132-
- toggle active signal subscriptions
133-
- keep subscriptions running and write them to the chosen destination file
147+
---
134148

135149
## Runtime options
136150

137-
Supported stream options:
151+
### Streaming
138152

139153
- `--window-semantics elapsed|ordinal`
140154
- `--backfill`
@@ -146,102 +160,101 @@ Supported stream options:
146160
- `--timeout <duration>`
147161
- `--no-reconnect`
148162

149-
Supported output modes:
163+
### Output formats
150164

151165
- `pretty`
152166
- `json`
153-
- `ndjson`
167+
- `ndjson` (recommended for pipelines)
154168

155-
Supported output filters:
169+
### Output filters
156170

157171
- `data`
158172
- `status`
159173
- `events`
160174
- `all`
161175

162-
## Local config
176+
---
177+
178+
## Configuration
163179

164-
The CLI stores config/auth in platform-standard config directories:
180+
Stored in platform-standard locations:
165181

166182
- macOS: `~/Library/Application Support/disc/`
167183
- Linux: `${XDG_CONFIG_HOME:-~/.config}/disc/`
168184
- Windows: `%APPDATA%/disc/`
169185

170-
Tracked files are:
186+
Files:
171187

172188
- `config.json`
173189
- `auth.json`
174190

175-
The API key is never written into repository files.
191+
🔐 API keys are stored locally and never committed to the repo.
176192

177-
## Homebrew release flow
193+
---
178194

179-
`disc-cli` is packaged for Homebrew as prebuilt release archives, not source builds on the user machine.
195+
## Development
180196

181-
Release archives contain only:
197+
Build locally:
182198

183-
- `disc`
184-
- `README.md`
185-
- `LICENSE`
199+
```bash
200+
cargo build
201+
```
186202

187-
Release automation lives in `.github/workflows/release.yml` and currently targets:
203+
Run:
188204

189-
- `aarch64-apple-darwin` on `macos-14`
190-
- `x86_64-apple-darwin` on `macos-13`
191-
- `x86_64-unknown-linux-gnu` on `ubuntu-24.04`
205+
```bash
206+
cargo run --bin disc -- --help
207+
```
192208

193-
Create a release tag:
209+
### Local wrapper
210+
211+
```bash
212+
./disc.sh auth whoami
213+
```
214+
215+
Defaults:
216+
217+
- HTTP: `http://localhost:3001`
218+
- WS: `ws://localhost:8097`
219+
- Client ID: `disc-cli-local`
220+
221+
Env precedence:
222+
223+
1. `DISC_LOCAL_API_KEY`
224+
2. `DISC_API_KEY`
225+
3. stored CLI auth
226+
227+
---
228+
229+
## Release & distribution (maintainers)
230+
231+
`disc-cli` is distributed as **prebuilt binaries** via GitHub Releases and installed via Homebrew.
232+
233+
Create a release:
194234

195235
```bash
196236
git tag v0.1.0
197237
git push origin v0.1.0
198238
```
199239

200-
The workflow will publish:
240+
Artifacts:
201241

202-
- `disc-aarch64-apple-darwin.tar.gz`
203-
- `disc-x86_64-apple-darwin.tar.gz`
204-
- `disc-x86_64-unknown-linux-gnu.tar.gz`
242+
- `disc-<target>.tar.gz`
205243
- `SHA256SUMS.txt`
206-
- `disc.rb`
244+
- `disc.rb` (Homebrew formula)
207245

208-
Local packaging smoke test:
246+
---
209247

210-
```bash
211-
cargo build --locked --release --bin disc
212-
./scripts/package-release.sh \
213-
--binary ./target/release/disc \
214-
--target "$(rustc -vV | sed -n 's/^host: //p')" \
215-
--output-dir ./dist
216-
```
248+
## Design principles
217249

218-
Local formula rendering smoke test:
250+
- 🧩 Native Rust binary (no runtime dependencies)
251+
- 🔌 Unix-first (stdout streaming, pipe-friendly)
252+
- ⚡ Low-latency real-time consumption
253+
- 🧱 Stable CLI interface over evolving backend
219254

220-
```bash
221-
./scripts/package-release.sh \
222-
--binary ./target/release/disc \
223-
--target aarch64-apple-darwin \
224-
--output-dir ./dist
225-
./scripts/package-release.sh \
226-
--binary ./target/release/disc \
227-
--target x86_64-apple-darwin \
228-
--output-dir ./dist
229-
./scripts/package-release.sh \
230-
--binary ./target/release/disc \
231-
--target x86_64-unknown-linux-gnu \
232-
--output-dir ./dist
233-
shasum -a 256 ./dist/disc-*.tar.gz > ./dist/SHA256SUMS.txt
234-
python3 ./scripts/render_homebrew_formula.py \
235-
--version 0.1.0 \
236-
--release-base-url https://github.com/disctech/disc-cli/releases/download/v0.1.0 \
237-
--checksums ./dist/SHA256SUMS.txt \
238-
--output ./dist/disc.rb
239-
```
255+
---
240256

241-
Publish to the tap after the GitHub release completes:
257+
## License
258+
259+
See `LICENSE`.
242260

243-
```bash
244-
brew tap disctech/tap
245-
brew install disctech/tap/disc
246-
disc --version
247-
```

0 commit comments

Comments
 (0)