|
| 1 | +# Gist CLI: Complete User Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Gist CLI is a powerful, git-style command-line tool for managing GitHub Gists, designed for seamless blog publishing and content management. Built with clean architecture principles, it provides a comprehensive set of tools for creating, managing, and synchronizing your blog posts. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- 📝 **Direct Publishing** - Create gists directly from files |
| 10 | +- 📋 **List & Browse** - View all your public gists |
| 11 | +- 🔍 **Search by Tags** - Filter gists using hashtags |
| 12 | +- 🔄 **Sync** - Keep local cache up-to-date with GitHub |
| 13 | +- 🔒 **Privacy Control** - Create private or public gists |
| 14 | +- 🎨 **Interactive TUI** - Terminal UI for gist management |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +### Quick Install |
| 19 | + |
| 20 | +```bash |
| 21 | +# Clone the repository |
| 22 | +git clone https://github.com/yourusername/gist |
| 23 | +cd gist |
| 24 | + |
| 25 | +# Build and install |
| 26 | +make build |
| 27 | +make install-cli |
| 28 | + |
| 29 | +# Verify installation |
| 30 | +gist version |
| 31 | +``` |
| 32 | + |
| 33 | +### Manual Installation |
| 34 | + |
| 35 | +```bash |
| 36 | +# Build binary |
| 37 | +go build -o gist gist.go |
| 38 | + |
| 39 | +# Install to system path |
| 40 | +sudo cp gist /usr/local/bin/ |
| 41 | +``` |
| 42 | + |
| 43 | +## Configuration |
| 44 | + |
| 45 | +### Authentication Methods |
| 46 | + |
| 47 | +1. **Environment Variables** |
| 48 | + ```bash |
| 49 | + export GITHUB_USER="your-github-username" |
| 50 | + export GITHUB_TOKEN="ghp_your_personal_access_token" |
| 51 | + ``` |
| 52 | + |
| 53 | +2. **Dotenv File** |
| 54 | + Create a `.env` file in your project or home directory: |
| 55 | + ``` |
| 56 | + GITHUB_USER=your-username |
| 57 | + GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here |
| 58 | + ``` |
| 59 | + |
| 60 | +3. **Interactive Setup** |
| 61 | + ```bash |
| 62 | + # Initialize configuration |
| 63 | + gist init |
| 64 | + ``` |
| 65 | + |
| 66 | +### Token Requirements |
| 67 | + |
| 68 | +Your GitHub personal access token needs: |
| 69 | +- `gist` scope to create and manage gists |
| 70 | +- Optional `read:user` for profile access |
| 71 | + |
| 72 | +## Basic Workflow |
| 73 | + |
| 74 | +### 1. Create Content |
| 75 | + |
| 76 | +Write your posts in Markdown: |
| 77 | +```bash |
| 78 | +vim my-post.md |
| 79 | +``` |
| 80 | + |
| 81 | +### 2. Stage Changes |
| 82 | + |
| 83 | +```bash |
| 84 | +# Stage a new post (private by default) |
| 85 | +gist add my-post.md -d "My Post Title #tag1 #tag2" |
| 86 | + |
| 87 | +# Stage as public post |
| 88 | +gist add -p my-post.md -d "Public Post #blog" |
| 89 | + |
| 90 | +# Stage multiple files |
| 91 | +gist add file1.md file2.md -d "Multi-file post" |
| 92 | +``` |
| 93 | + |
| 94 | +### 3. Check Status |
| 95 | + |
| 96 | +```bash |
| 97 | +gist status |
| 98 | + |
| 99 | +# Example output: |
| 100 | +# Changes to be pushed (2): |
| 101 | +# new file: my-post.md |
| 102 | +# → My Post Title #tag1 #tag2 |
| 103 | +# new file: another.md |
| 104 | +# → Another Post #blog |
| 105 | +``` |
| 106 | + |
| 107 | +### 4. Push to GitHub |
| 108 | + |
| 109 | +```bash |
| 110 | +gist push |
| 111 | +``` |
| 112 | + |
| 113 | +## Commands Reference |
| 114 | + |
| 115 | +| Command | Alias | Description | |
| 116 | +|---------|-------|-------------| |
| 117 | +| `gist init` | | Initialize configuration | |
| 118 | +| `gist status` | `st` | Show staged changes | |
| 119 | +| `gist add` | | Stage files for upload | |
| 120 | +| `gist rm` | `remove` | Stage gist for deletion | |
| 121 | +| `gist tag` | | Add tags to a gist | |
| 122 | +| `gist push` | | Upload changes to GitHub | |
| 123 | +| `gist pull` | | Sync from GitHub | |
| 124 | +| `gist list` | `ls` | List all gists | |
| 125 | +| `gist show` | | Show gist details | |
| 126 | +| `gist log` | | Show gist history | |
| 127 | +| `gist diff` | | Show staged changes | |
| 128 | +| `gist search` | | Search gists | |
| 129 | +| `gist reset` | | Unstage all changes | |
| 130 | +| `gist config` | | Manage configuration | |
| 131 | +| `gist clean` | | Remove cache | |
| 132 | +| `gist help` | | Show help | |
| 133 | +| `gist version` | | Show version | |
| 134 | + |
| 135 | +## Advanced Features |
| 136 | + |
| 137 | +### Manage Existing Posts |
| 138 | + |
| 139 | +```bash |
| 140 | +# Pull latest gists |
| 141 | +gist pull |
| 142 | + |
| 143 | +# List posts |
| 144 | +gist list |
| 145 | + |
| 146 | +# Search gists |
| 147 | +gist search docker |
| 148 | + |
| 149 | +# Show gist details |
| 150 | +gist show abc123d |
| 151 | +``` |
| 152 | + |
| 153 | +### Modify Posts |
| 154 | + |
| 155 | +```bash |
| 156 | +# Add tags |
| 157 | +gist tag abc123d tutorial featured |
| 158 | + |
| 159 | +# Remove post |
| 160 | +gist rm abc123d |
| 161 | + |
| 162 | +# Toggle visibility |
| 163 | +gist toggle abc123d |
| 164 | +``` |
| 165 | + |
| 166 | +## Caching |
| 167 | + |
| 168 | +- **Location**: `~/.gist-cache/` |
| 169 | +- **TTL**: 5 minutes |
| 170 | +- **Force Refresh**: `gist sync` |
| 171 | + |
| 172 | +## Best Practices |
| 173 | + |
| 174 | +1. Always pull before making changes |
| 175 | + ```bash |
| 176 | + gist pull |
| 177 | + gist status |
| 178 | + ``` |
| 179 | + |
| 180 | +2. Use descriptive commit messages |
| 181 | + ```bash |
| 182 | + gist add post.md -d "Tutorial: Docker multi-stage builds #docker #tutorial" |
| 183 | + ``` |
| 184 | + |
| 185 | +3. Review before pushing |
| 186 | + ```bash |
| 187 | + gist diff |
| 188 | + gist push |
| 189 | + ``` |
| 190 | + |
| 191 | +4. Keep cache fresh |
| 192 | + ```bash |
| 193 | + gist pull |
| 194 | + ``` |
| 195 | + |
| 196 | +5. Organize with tags |
| 197 | + ```bash |
| 198 | + gist tag old-post-id archive deprecated |
| 199 | + ``` |
| 200 | + |
| 201 | +## Troubleshooting |
| 202 | + |
| 203 | +### Permission Issues |
| 204 | + |
| 205 | +```bash |
| 206 | +# If /usr/local/bin is not writable |
| 207 | +sudo make install-cli |
| 208 | + |
| 209 | +# Or install to user directory |
| 210 | +mkdir -p ~/bin |
| 211 | +cp gist ~/bin/ |
| 212 | +export PATH="$HOME/bin:$PATH" |
| 213 | +``` |
| 214 | + |
| 215 | +### Token Problems |
| 216 | + |
| 217 | +```bash |
| 218 | +# Test configuration |
| 219 | +gist config |
| 220 | +gist pull |
| 221 | + |
| 222 | +# Update token if needed |
| 223 | +gist config github.token ghp_new_token |
| 224 | +``` |
| 225 | + |
| 226 | +### Cache Problems |
| 227 | + |
| 228 | +```bash |
| 229 | +# Clear and rebuild cache |
| 230 | +gist clean |
| 231 | +gist pull |
| 232 | +``` |
| 233 | + |
| 234 | +## Tips & Tricks |
| 235 | + |
| 236 | +### Shell Aliases |
| 237 | + |
| 238 | +Add to `.bashrc` or `.zshrc`: |
| 239 | +```bash |
| 240 | +alias gs='gist status' |
| 241 | +alias ga='gist add' |
| 242 | +alias gp='gist push' |
| 243 | +alias gl='gist list' |
| 244 | +alias gd='gist diff' |
| 245 | +``` |
| 246 | + |
| 247 | +### Auto-sync |
| 248 | + |
| 249 | +Add to crontab for hourly sync: |
| 250 | +```bash |
| 251 | +0 * * * * /usr/local/bin/gist pull |
| 252 | +``` |
| 253 | + |
| 254 | +## Contributing |
| 255 | + |
| 256 | +1. Fork the repository |
| 257 | +2. Create your feature branch (`git checkout -b feature/amazing`) |
| 258 | +3. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 259 | +4. Push to the branch (`git push origin feature/amazing`) |
| 260 | +5. Open a Pull Request |
| 261 | + |
| 262 | +## License |
| 263 | + |
| 264 | +MIT License - see LICENSE file for details |
0 commit comments