Skip to content

Commit 7ca9b9b

Browse files
committed
docs: add CLI reference and update terminal usage guide
1 parent 96a2a1a commit 7ca9b9b

File tree

3 files changed

+113
-79
lines changed

3 files changed

+113
-79
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ The difference between *a tool you use* and *a tool you own.*
189189

190190
**Security hardened** — rate limiting on all write endpoints, magic number file validation, filename sanitisation, and forced download for executable file types.
191191

192+
**CLI companion**`instbyte send`, `instbyte watch`, and `instbyte status` let you push files, pipe command output, sync clipboard, and check server health without opening a browser. Auto-discovers the running server from your working directory.
193+
192194
---
193195

194196
## Broadcasting
@@ -220,7 +222,7 @@ For HTTPS setup and advanced network configuration, see the [Deployment Guide](d
220222
git clone https://github.com/mohitgauniyal/instbyte
221223
cd instbyte
222224
npm install
223-
node server/server.js
225+
node bin/instbyte.js
224226
```
225227

226228
---
@@ -237,9 +239,19 @@ node server/server.js
237239

238240
---
239241

240-
## Terminal Usage
242+
## CLI & Terminal Usage
243+
244+
Send files, pipe command output, watch channels, and check server status from your terminal — no browser needed.
245+
246+
```bash
247+
instbyte send ./build.zip --channel assets
248+
instbyte send "http://staging.myapp.com"
249+
git log --oneline -20 | instbyte send
250+
instbyte watch --channel projects
251+
instbyte status
252+
```
241253

242-
Push content from your terminal using curl — no browser needed. See [Terminal Usage Guide](docs/terminal-usage.md).
254+
See the [Terminal Usage Guide](docs/terminal-usage.md) for the full CLI reference, CI/CD setup, and raw curl fallback.
243255

244256
---
245257

@@ -253,7 +265,7 @@ Instbyte follows [Semantic Versioning](https://semver.org). See [Releases](https
253265

254266
Instbyte is intentionally lightweight and LAN-first. If you want to extend it — CLI tools, themes, integrations — open an issue or submit a pull request.
255267

256-
The codebase has a full test suite (195 tests across unit and integration). Run `npm test` before submitting anything. Issues tagged **good first issue** are a good starting point.
268+
The codebase has a full test suite (214 tests across unit and integration). Run `npm test` before submitting anything. Issues tagged **good first issue** are a good starting point.
257269

258270
---
259271

docs/terminal-usage.md

Lines changed: 96 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,138 @@
11
# Terminal Usage
22

3-
Instbyte exposes a simple HTTP API — push content directly from your terminal using `curl`, no browser needed.
3+
Instbyte has a first-class CLI for sending, watching, and checking server status — no browser needed.
44

5-
Replace `192.168.x.x:3000` with the URL shown when Instbyte starts.
5+
Replace `192.168.x.x:3000` with the URL shown when Instbyte starts. If you're working in the same directory (or any subdirectory) as where the server was started, the URL is discovered automatically.
66

77
---
88

9-
## Send text or a link
9+
## CLI
10+
11+
### Send a file
1012
```bash
11-
curl -X POST http://192.168.x.x:3000/push \
12-
-H "Content-Type: text/plain" \
13-
-d "hello from terminal"
13+
instbyte send ./build.zip
14+
instbyte send ./error.log --channel projects
15+
instbyte send ./report.pdf --channel assets --passphrase myteam
1416
```
1517

16-
Use `X-Channel` and `X-Uploader` headers to control where it lands. Both default to `general` and `terminal` if omitted.
18+
### Send text or a link
1719
```bash
18-
curl -X POST http://192.168.x.x:3000/push \
19-
-H "Content-Type: text/plain" \
20-
-H "X-Channel: projects" \
21-
-H "X-Uploader: mohit" \
22-
-d "targeted push"
20+
instbyte send "http://staging.myapp.com"
21+
instbyte send "quick note for the team" --channel projects
2322
```
2423

25-
---
24+
### Pipe anything in
25+
```bash
26+
npm run build 2>&1 | instbyte send
27+
git log --oneline -20 | instbyte send
28+
docker logs my-container | instbyte send --channel projects
29+
cat error.log | instbyte send
30+
```
2631

27-
## Pipe command output
32+
> Windows: use PowerShell or CMD for piping. Git Bash has a known stdin limitation with native executables.
2833
29-
Any command output — logs, build errors, git history — pipes directly. No quoting or escaping needed.
34+
### Watch a channel — auto-copy new text to clipboard
3035
```bash
31-
# build output
32-
npm run build 2>&1 | curl -X POST http://192.168.x.x:3000/push \
33-
-H "Content-Type: text/plain" \
34-
--data-binary @-
35-
36-
# directory listing
37-
ls -la | curl -X POST http://192.168.x.x:3000/push \
38-
-H "Content-Type: text/plain" \
39-
--data-binary @-
36+
instbyte watch # watches general channel
37+
instbyte watch --channel projects # specific channel
38+
instbyte watch --output # print to stdout instead of clipboard
39+
instbyte watch --output | grep "error" # pipeable
40+
```
4041

41-
# git log
42-
git log --oneline -20 | curl -X POST http://192.168.x.x:3000/push \
43-
-H "Content-Type: text/plain" \
44-
--data-binary @-
42+
New text items are silently copied to your clipboard. File items print the download URL.
4543

46-
# docker logs
47-
docker logs my-container 2>&1 | curl -X POST http://192.168.x.x:3000/push \
48-
-H "Content-Type: text/plain" \
49-
--data-binary @-
44+
### Check server status
45+
```bash
46+
instbyte status
47+
instbyte status --server http://192.168.x.x:3000
5048
```
5149

5250
---
5351

54-
## Send a file's contents as text
55-
```bash
56-
curl -X POST http://192.168.x.x:3000/push \
57-
-H "Content-Type: text/plain" \
58-
--data-binary @error.log
59-
```
52+
## Server auto-discovery
6053

61-
This works for any text file — logs, configs, `.env` snapshots, stack traces. The content appears in the feed with syntax highlighting if the extension is recognised.
54+
When the server starts, it writes a small runtime config to `instbyte-data/.runtime.json` with the server URL and passphrase. The CLI picks this up automatically by walking up from your current directory — the same way git finds `.git`.
6255

63-
> Use `/upload` instead if you want the file itself to be downloadable rather than read inline.
56+
Priority order for every CLI command:
57+
1. `--server` / `--passphrase` flags
58+
2. `INSTBYTE_URL` / `INSTBYTE_PASS` environment variables
59+
3. `instbyte-data/.runtime.json` found by walking up from cwd
60+
4. `http://localhost:3000` fallback
6461

6562
---
6663

67-
## Upload a file
64+
## CI/CD
65+
66+
Environment variables are the clean path for CI — set once as a secret, use everywhere:
6867

69-
Any file type — images, PDFs, zips, executables, media.
7068
```bash
71-
curl -X POST http://192.168.x.x:3000/upload \
72-
-F "file=@./screenshot.png" \
73-
-F "channel=general" \
74-
-F "uploader=terminal"
69+
# Set in CI environment
70+
INSTBYTE_URL=http://192.168.x.x:3000
71+
INSTBYTE_PASS=myteam
7572
```
7673

77-
---
78-
79-
## With auth enabled
80-
81-
Pass the passphrase as a header — works from any terminal or CI environment without needing a browser session.
82-
```bash
83-
curl -X POST http://192.168.x.x:3000/push \
84-
-H "Content-Type: text/plain" \
85-
-H "X-Passphrase: yourpassword" \
86-
--data-binary @error.log
74+
```yaml
75+
# GitHub Actions
76+
- name: Share build artifact
77+
run: npx instbyte send ./dist/app.zip --channel assets
8778
```
8879
89-
All endpoints accept `X-Passphrase`. Upload too:
90-
```bash
91-
curl -X POST http://192.168.x.x:3000/upload \
92-
-H "X-Passphrase: yourpassword" \
93-
-F "file=@./build.zip" \
94-
-F "channel=assets" \
95-
-F "uploader=CI"
80+
```json
81+
// package.json scripts
82+
{
83+
"scripts": {
84+
"build": "webpack && instbyte send ./dist/build.zip --channel assets",
85+
"test": "vitest run 2>&1 | instbyte send --channel projects"
86+
}
87+
}
9688
```
9789

9890
---
9991

100-
## Quick reference — headers
92+
## Options
10193

102-
| Header | Applies to | Default | Description |
94+
| Flag | Commands | Default | Description |
10395
|---|---|---|---|
104-
| `X-Channel` | `/push`, `/text` | `general` | Channel to post into |
105-
| `X-Uploader` | `/push`, `/text` | `terminal` | Display name in the feed |
106-
| `X-Passphrase` | all endpoints || Passphrase if auth is enabled |
96+
| `--server <url>` | all | auto-discovered | Server URL |
97+
| `--channel <name>` | send, watch | `general` | Target channel |
98+
| `--passphrase <pass>` | all | auto-discovered | Passphrase if auth is enabled |
99+
| `--uploader <name>` | send | OS username | Display name for sent items |
100+
| `--output` | watch || Print to stdout instead of clipboard |
101+
| `--quiet` | send || Suppress confirmation output |
107102

108103
---
109104

110-
## Use cases
105+
## Raw HTTP (curl)
111106

112-
- Pipe stack traces or build output from CI straight into a shared channel
113-
- Send `.env` snapshots or config dumps from a remote server
114-
- Push deployment notifications to a team channel
115-
- Share API responses or debug output without leaving the terminal
116-
```
107+
The HTTP API is also available directly — useful for environments without the CLI installed.
108+
109+
```bash
110+
# Send text
111+
curl -X POST http://192.168.x.x:3000/push \
112+
-H "Content-Type: text/plain" \
113+
-d "hello from terminal"
114+
115+
# Send to a specific channel
116+
curl -X POST http://192.168.x.x:3000/push \
117+
-H "Content-Type: text/plain" \
118+
-H "X-Channel: projects" \
119+
-H "X-Uploader: mohit" \
120+
-d "targeted push"
121+
122+
# Pipe command output
123+
npm run build 2>&1 | curl -X POST http://192.168.x.x:3000/push \
124+
-H "Content-Type: text/plain" \
125+
--data-binary @-
126+
127+
# Upload a file
128+
curl -X POST http://192.168.x.x:3000/upload \
129+
-F "file=@./screenshot.png" \
130+
-F "channel=general" \
131+
-F "uploader=terminal"
132+
133+
# With auth
134+
curl -X POST http://192.168.x.x:3000/push \
135+
-H "Content-Type: text/plain" \
136+
-H "X-Passphrase: yourpassword" \
137+
--data-binary @error.log
138+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "instbyte",
3-
"version": "1.11.1",
3+
"version": "1.12.0",
44
"description": "A self-hosted LAN sharing utility for fast, frictionless file, link, and snippet exchange across devices — no cloud required.",
55
"main": "bin/instbyte.js",
66
"bin": {

0 commit comments

Comments
 (0)