README.md 3.9 K raw
1
# Sipp
2
3
![cover](https://files.stevedylan.dev/sipp-rust.png)
4
5
Minimal code sharing in Rust
6
7
## Features
8
9
- Single binary for Server, CLI, and TUI
10
- Web UI to create, copy, and share code snippets with syntax highlighting
11
- Interactive TUI with authenticated access for snippet management
12
- Minimal, fast, and low memory consumption
13
14
## Quickstart
15
16
**1. Install with Cargo**
17
18
Install the binary from Crates.io
19
20
```bash
21
cargo install sipp-so
22
```
23
24
To confirm it was installed correctly run the following
25
26
```bash
27
sipp --help
28
```
29
30
**2. Start Server**
31
32
For demo purposes you can run this locally, but ideally this would be run in a deployment server with a proper ENV setup with your admin key.
33
34
```bash
35
sipp server --port 3000
36
```
37
38
**3. Create a Snippet**
39
40
You can either open up `http://localhost:3000` and create a snippet in a web browser, or use the TUI. In the same directory, open a new terminal window and use 
41
42
```bash
43
# Path to file
44
sipp path/to/file.rs
45
46
# Or use the interactive tui 
47
sipp
48
```
49
50
## Server
51
52
Sipp includes a built-in web server powered by Axum. Start it with:
53
54
```bash
55
sipp server --port 3000 --host localhost
56
```
57
58
### Environment Variables
59
60
| Variable | Description |
61
|---|---|
62
| `SIPP_API_KEY` | API key for protecting endpoints |
63
| `SIPP_AUTH_ENDPOINTS` | Comma-separated list of endpoints requiring auth: `api_list`, `api_create`, `api_get`, `api_delete`, `all`, or `none` (defaults to `api_delete,api_list`) |
64
65
The server stores snippets in a local `sipp.sqlite` SQLite database.
66
67
### API Endpoints
68
69
| Method | Endpoint | Description |
70
|---|---|---|
71
| `GET` | `/api/snippets` | List all snippets |
72
| `POST` | `/api/snippets` | Create a snippet (`{"name": "...", "content": "..."}`) |
73
| `GET` | `/api/snippets/{short_id}` | Get a snippet by ID |
74
| `DELETE` | `/api/snippets/{short_id}` | Delete a snippet by ID |
75
76
Authenticated endpoints require an `x-api-key` header.
77
78
## Web UI
79
80
The server serves a web interface at the root URL where you can create, view, and share code snippets with syntax highlighting. Each snippet gets a shareable link at `/s/{short_id}`.
81
82
## CLI
83
84
Upload a file directly from the command line:
85
86
```bash
87
sipp path/to/file.rs
88
```
89
90
This creates a snippet and prints the shareable link (also copied to clipboard).
91
92
## TUI
93
94
Launch the interactive terminal UI:
95
96
```bash
97
sipp
98
```
99
100
### Keybindings
101
102
| Key | Action |
103
|---|---|
104
| `j`/`↓` | Move down / Scroll down |
105
| `k`/`↑` | Move up / Scroll up |
106
| `Enter` | Focus content pane |
107
| `Esc` | Back / Quit |
108
| `y` | Copy snippet content |
109
| `Y` | Copy snippet link |
110
| `o` | Open in browser |
111
| `d` | Delete snippet |
112
| `c` | Create snippet |
113
| `r` | Refresh snippets (remote only) |
114
| `q` | Quit |
115
| `?` | Toggle help |
116
117
## Configuration
118
119
Save your remote URL and API key to `~/.config/sipp/config.toml` so you can access your sipp db anywhere:
120
121
```bash
122
sipp auth
123
```
124
125
You can also pass these as flags or environment variables:
126
127
```bash
128
sipp --remote http://your-server.com --api-key YOUR_KEY
129
# or
130
export SIPP_REMOTE_URL=http://your-server.com
131
export SIPP_API_KEY=YOUR_KEY
132
```
133
134
## Deployment
135
136
### Systemd
137
138
Create a service file at `/etc/systemd/system/sipp.service`:
139
140
```ini
141
[Unit]
142
Description=Sipp snippet server
143
After=network.target
144
145
[Service]
146
ExecStart=/usr/local/bin/sipp server --port 3000 --host 0.0.0.0
147
Environment=SIPP_API_KEY=your-secret-key
148
WorkingDirectory=/var/lib/sipp
149
Restart=on-failure
150
151
[Install]
152
WantedBy=multi-user.target
153
```
154
155
```bash
156
sudo systemctl enable --now sipp
157
```
158
159
### Docker
160
161
A `Dockerfile` and `docker-compose.yml` are included in the repository.
162
163
```bash
164
# Using Docker Compose (recommended)
165
SIPP_API_KEY=your-secret-key docker compose up -d
166
167
# Or build and run manually
168
docker build -t sipp .
169
docker run -p 3000:3000 -e SIPP_API_KEY=your-secret-key -v sipp-data:/data sipp
170
```
171
172
### Railway
173
174
1. Connect your repository to [Railway](https://railway.app)
175
2. Set the environment variables `SIPP_API_KEY` and optionally `SIPP_AUTH_ENDPOINTS`