chore: update README
08846d9b
1 file(s) · +182 −0
| 1 | + | # Sipp |
|
| 2 | + | ||
| 3 | + |  |
|
| 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 | + | ||
| 13 | + | ## Quickstart |
|
| 14 | + | ||
| 15 | + | **1. Install with Cargo** |
|
| 16 | + | ||
| 17 | + | Install the binary from Crates.io |
|
| 18 | + | ||
| 19 | + | ```bash |
|
| 20 | + | cargo install sipp-so |
|
| 21 | + | ``` |
|
| 22 | + | ||
| 23 | + | To confirm it was installed correctly run the following |
|
| 24 | + | ||
| 25 | + | ```bash |
|
| 26 | + | sipp --help |
|
| 27 | + | ``` |
|
| 28 | + | ||
| 29 | + | **2. Start Server** |
|
| 30 | + | ||
| 31 | + | 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. |
|
| 32 | + | ||
| 33 | + | ```bash |
|
| 34 | + | sipp server --port 3000 |
|
| 35 | + | ``` |
|
| 36 | + | ||
| 37 | + | **3. Create a Snippet** |
|
| 38 | + | ||
| 39 | + | 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 |
|
| 40 | + | ||
| 41 | + | ```bash |
|
| 42 | + | # Path to file |
|
| 43 | + | sipp path/to/file.rs |
|
| 44 | + | ||
| 45 | + | # Or use the interactive tui |
|
| 46 | + | sipp |
|
| 47 | + | ``` |
|
| 48 | + | ||
| 49 | + | ## Server |
|
| 50 | + | ||
| 51 | + | Sipp includes a built-in web server powered by Axum. Start it with: |
|
| 52 | + | ||
| 53 | + | ```bash |
|
| 54 | + | sipp server --port 3000 --host localhost |
|
| 55 | + | ``` |
|
| 56 | + | ||
| 57 | + | ### Environment Variables |
|
| 58 | + | ||
| 59 | + | | Variable | Description | |
|
| 60 | + | |---|---| |
|
| 61 | + | | `SIPP_API_KEY` | API key for protecting endpoints | |
|
| 62 | + | | `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`) | |
|
| 63 | + | ||
| 64 | + | The server stores snippets in a local `sipp.sqlite` SQLite database. |
|
| 65 | + | ||
| 66 | + | ### API Endpoints |
|
| 67 | + | ||
| 68 | + | | Method | Endpoint | Description | |
|
| 69 | + | |---|---|---| |
|
| 70 | + | | `GET` | `/api/snippets` | List all snippets | |
|
| 71 | + | | `POST` | `/api/snippets` | Create a snippet (`{"name": "...", "content": "..."}`) | |
|
| 72 | + | | `GET` | `/api/snippets/{short_id}` | Get a snippet by ID | |
|
| 73 | + | | `DELETE` | `/api/snippets/{short_id}` | Delete a snippet by ID | |
|
| 74 | + | ||
| 75 | + | Authenticated endpoints require an `x-api-key` header. |
|
| 76 | + | ||
| 77 | + | ## Web UI |
|
| 78 | + | ||
| 79 | + | 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}`. |
|
| 80 | + | ||
| 81 | + | ## CLI |
|
| 82 | + | ||
| 83 | + | Upload a file directly from the command line: |
|
| 84 | + | ||
| 85 | + | ```bash |
|
| 86 | + | sipp path/to/file.rs |
|
| 87 | + | ``` |
|
| 88 | + | ||
| 89 | + | This creates a snippet and prints the shareable link (also copied to clipboard). |
|
| 90 | + | ||
| 91 | + | ## TUI |
|
| 92 | + | ||
| 93 | + | Launch the interactive terminal UI: |
|
| 94 | + | ||
| 95 | + | ```bash |
|
| 96 | + | sipp |
|
| 97 | + | ``` |
|
| 98 | + | ||
| 99 | + | ### Keybindings |
|
| 100 | + | ||
| 101 | + | | Key | Action | |
|
| 102 | + | |---|---| |
|
| 103 | + | | `j`/`↓` | Move down / Scroll down | |
|
| 104 | + | | `k`/`↑` | Move up / Scroll up | |
|
| 105 | + | | `Enter` | Focus content pane | |
|
| 106 | + | | `Esc` | Back / Quit | |
|
| 107 | + | | `y` | Copy snippet content | |
|
| 108 | + | | `Y` | Copy snippet link | |
|
| 109 | + | | `o` | Open in browser | |
|
| 110 | + | | `d` | Delete snippet | |
|
| 111 | + | | `c` | Create snippet | |
|
| 112 | + | | `r` | Refresh snippets (remote only) | |
|
| 113 | + | | `q` | Quit | |
|
| 114 | + | | `?` | Toggle help | |
|
| 115 | + | ||
| 116 | + | ## Configuration |
|
| 117 | + | ||
| 118 | + | Save your remote URL and API key to `~/.config/sipp/config.toml` so you can access your sipp db anywhere: |
|
| 119 | + | ||
| 120 | + | ```bash |
|
| 121 | + | sipp auth |
|
| 122 | + | ``` |
|
| 123 | + | ||
| 124 | + | You can also pass these as flags or environment variables: |
|
| 125 | + | ||
| 126 | + | ```bash |
|
| 127 | + | sipp --remote http://your-server.com --api-key YOUR_KEY |
|
| 128 | + | # or |
|
| 129 | + | export SIPP_REMOTE_URL=http://your-server.com |
|
| 130 | + | export SIPP_API_KEY=YOUR_KEY |
|
| 131 | + | ``` |
|
| 132 | + | ||
| 133 | + | ## Deployment |
|
| 134 | + | ||
| 135 | + | ### Systemd |
|
| 136 | + | ||
| 137 | + | Create a service file at `/etc/systemd/system/sipp.service`: |
|
| 138 | + | ||
| 139 | + | ```ini |
|
| 140 | + | [Unit] |
|
| 141 | + | Description=Sipp snippet server |
|
| 142 | + | After=network.target |
|
| 143 | + | ||
| 144 | + | [Service] |
|
| 145 | + | ExecStart=/usr/local/bin/sipp server --port 3000 --host 0.0.0.0 |
|
| 146 | + | Environment=SIPP_API_KEY=your-secret-key |
|
| 147 | + | WorkingDirectory=/var/lib/sipp |
|
| 148 | + | Restart=on-failure |
|
| 149 | + | ||
| 150 | + | [Install] |
|
| 151 | + | WantedBy=multi-user.target |
|
| 152 | + | ``` |
|
| 153 | + | ||
| 154 | + | ```bash |
|
| 155 | + | sudo systemctl enable --now sipp |
|
| 156 | + | ``` |
|
| 157 | + | ||
| 158 | + | ### Docker |
|
| 159 | + | ||
| 160 | + | ```dockerfile |
|
| 161 | + | FROM rust:1-slim AS builder |
|
| 162 | + | WORKDIR /app |
|
| 163 | + | COPY . . |
|
| 164 | + | RUN cargo build --release |
|
| 165 | + | ||
| 166 | + | FROM debian:bookworm-slim |
|
| 167 | + | COPY --from=builder /app/target/release/sipp /usr/local/bin/sipp |
|
| 168 | + | WORKDIR /data |
|
| 169 | + | EXPOSE 3000 |
|
| 170 | + | CMD ["sipp", "server", "--port", "3000", "--host", "0.0.0.0"] |
|
| 171 | + | ``` |
|
| 172 | + | ||
| 173 | + | ```bash |
|
| 174 | + | docker build -t sipp . |
|
| 175 | + | docker run -p 3000:3000 -e SIPP_API_KEY=your-secret-key -v sipp-data:/data sipp |
|
| 176 | + | ``` |
|
| 177 | + | ||
| 178 | + | ### Railway |
|
| 179 | + | ||
| 180 | + | 1. Connect your repository to [Railway](https://railway.app) |
|
| 181 | + | 2. Set the environment variables `SIPP_API_KEY` and optionally `SIPP_AUTH_ENDPOINTS` |
|
| 182 | + | 3. Set the start command: `sipp server --port $PORT --host 0.0.0.0` |