|
| 1 | +# Temper CLI |
| 2 | + |
| 3 | +Homebrew for code snippets. Run, search, and edit reusable code utilities from your terminal. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +curl -fsSL https://tempercode.dev/install.sh | bash |
| 9 | +``` |
| 10 | + |
| 11 | +Works on macOS, Linux, and WSL. No dependencies required. |
| 12 | + |
| 13 | +### Manual Installation |
| 14 | + |
| 15 | +Download the latest binary for your platform from [Releases](https://github.com/handcraftbyte/temper-cli/releases) and add it to your PATH. |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### Run a snippet |
| 20 | + |
| 21 | +Execute JavaScript snippets directly in your terminal: |
| 22 | + |
| 23 | +```bash |
| 24 | +# Using named arguments |
| 25 | +temper run title-case --str="hello world" |
| 26 | +# Hello World |
| 27 | + |
| 28 | +# Using stdin |
| 29 | +echo "hello world" | temper run pascal-case |
| 30 | +# HelloWorld |
| 31 | +``` |
| 32 | + |
| 33 | +### Pipeline support |
| 34 | + |
| 35 | +Chain snippets with Unix pipes: |
| 36 | + |
| 37 | +```bash |
| 38 | +echo "[3,1,4,1,5,9]" | temper run array-sort |
| 39 | +# [1,1,3,4,5,9] |
| 40 | +``` |
| 41 | + |
| 42 | +### Search for snippets |
| 43 | + |
| 44 | +```bash |
| 45 | +temper search json |
| 46 | +# Found 5 snippet(s): |
| 47 | +# |
| 48 | +# json-parse Parse JSON string to object |
| 49 | +# json-stringify Convert object to JSON string |
| 50 | +# ... |
| 51 | +``` |
| 52 | + |
| 53 | +### List all snippets |
| 54 | + |
| 55 | +```bash |
| 56 | +temper list |
| 57 | +``` |
| 58 | + |
| 59 | +Filter by type: |
| 60 | + |
| 61 | +```bash |
| 62 | +temper list -t utility |
| 63 | +temper list -t algorithm |
| 64 | +``` |
| 65 | + |
| 66 | +### View snippet details |
| 67 | + |
| 68 | +```bash |
| 69 | +temper info slugify |
| 70 | +# SLUGIFY |
| 71 | +# Convert a string to a URL-friendly slug |
| 72 | +# |
| 73 | +# PARAMETERS |
| 74 | +# str (string, required) - The string to convert |
| 75 | +# |
| 76 | +# CODE |
| 77 | +# str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-") |
| 78 | +# |
| 79 | +# EXAMPLE OUTPUT |
| 80 | +# hello-world |
| 81 | +``` |
| 82 | + |
| 83 | +### Edit a snippet locally |
| 84 | + |
| 85 | +Download a snippet and open it in your editor: |
| 86 | + |
| 87 | +```bash |
| 88 | +temper edit slugify |
| 89 | +``` |
| 90 | + |
| 91 | +Uses `$EDITOR` environment variable. |
| 92 | + |
| 93 | +### Open in browser |
| 94 | + |
| 95 | +```bash |
| 96 | +temper open slugify |
| 97 | +``` |
| 98 | + |
| 99 | +### Manage cache |
| 100 | + |
| 101 | +Snippets are cached locally for offline use. |
| 102 | + |
| 103 | +```bash |
| 104 | +# Refresh cache with latest snippets |
| 105 | +temper cache refresh |
| 106 | + |
| 107 | +# Clear all cached snippets |
| 108 | +temper cache clear |
| 109 | + |
| 110 | +# Show cache status |
| 111 | +temper cache status |
| 112 | +``` |
| 113 | + |
| 114 | +## Commands |
| 115 | + |
| 116 | +| Command | Description | |
| 117 | +|---------|-------------| |
| 118 | +| `run <slug>` | Execute a JavaScript snippet | |
| 119 | +| `search <query>` | Search for snippets by name or description | |
| 120 | +| `list` | List all available snippets | |
| 121 | +| `info <slug>` | Show detailed snippet information | |
| 122 | +| `edit <slug>` | Download and open in $EDITOR | |
| 123 | +| `open <slug>` | Open snippet in browser | |
| 124 | +| `cache refresh` | Update local snippet cache | |
| 125 | +| `cache clear` | Clear cached snippets | |
| 126 | +| `cache status` | Show cache statistics | |
| 127 | + |
| 128 | +## Configuration |
| 129 | + |
| 130 | +Environment variables: |
| 131 | + |
| 132 | +| Variable | Description | Default | |
| 133 | +|----------|-------------|---------| |
| 134 | +| `TEMPER_API_URL` | API base URL | `https://tempercode.dev` | |
| 135 | +| `TEMPER_CACHE_DIR` | Cache directory | `~/.temper/cache` | |
| 136 | +| `EDITOR` | Editor for `edit` command | `vim` | |
| 137 | + |
| 138 | +## Building from source |
| 139 | + |
| 140 | +Requires [Bun](https://bun.sh). |
| 141 | + |
| 142 | +```bash |
| 143 | +# Install dependencies |
| 144 | +bun install |
| 145 | + |
| 146 | +# Run in development |
| 147 | +bun run dev --help |
| 148 | + |
| 149 | +# Build single binary |
| 150 | +bun run build |
| 151 | + |
| 152 | +# Build for all platforms |
| 153 | +bun run build:all |
| 154 | +``` |
| 155 | + |
| 156 | +## License |
| 157 | + |
| 158 | +MIT |
0 commit comments