|
| 1 | +# 📖 Man Page Management Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The `emojify` command includes a Unix manual page that is distributed through package managers. This follows the standard approach used by major Go CLI tools like GitHub CLI, kubectl, and Helm. |
| 6 | + |
| 7 | +## 🎯 Distribution Methods |
| 8 | + |
| 9 | +### **Package Manager Integration** ✅ IMPLEMENTED |
| 10 | + |
| 11 | +Each package manager automatically installs the man page from `docs/man/emojify.1`: |
| 12 | + |
| 13 | +#### **🍎 Homebrew (macOS/Linux)** |
| 14 | + |
| 15 | +```ruby |
| 16 | +# In Formula/emojify-go.rb |
| 17 | +if File.exist?("docs/man/emojify.1") |
| 18 | + man1.install "docs/man/emojify.1" # Automatic installation |
| 19 | +end |
| 20 | +``` |
| 21 | + |
| 22 | +**Installation**: `brew install damienbutt/tap/emojify-go` |
| 23 | +**Man page location**: `/opt/homebrew/share/man/man1/emojify.1` |
| 24 | +**Usage**: `man emojify` |
| 25 | + |
| 26 | +#### **🐧 AUR (Arch Linux)** |
| 27 | + |
| 28 | +```bash |
| 29 | +# In PKGBUILD |
| 30 | +install -Dm644 docs/man/emojify.1 "$pkgdir/usr/share/man/man1/emojify.1" |
| 31 | +``` |
| 32 | + |
| 33 | +**Installation**: `yay -S emojify-go-bin` |
| 34 | +**Man page location**: `/usr/share/man/man1/emojify.1` |
| 35 | +**Usage**: `man emojify` |
| 36 | + |
| 37 | +#### **🪟 Chocolatey (Windows)** |
| 38 | + |
| 39 | +```powershell |
| 40 | +# For WSL/MSYS2/Cygwin compatibility |
| 41 | +$manDir = Join-Path $env:ChocolateyInstall 'share\man\man1' |
| 42 | +Copy-Item -Path $manPath -Destination (Join-Path $manDir 'emojify.1') |
| 43 | +``` |
| 44 | + |
| 45 | +**Installation**: `choco install emojify-go` |
| 46 | +**Man page location**: `C:\ProgramData\chocolatey\share\man\man1\emojify.1` |
| 47 | +**Usage**: `man emojify` (in WSL/MSYS2/Cygwin) |
| 48 | + |
| 49 | +### **Manual Installation** |
| 50 | + |
| 51 | +For direct binary downloads: |
| 52 | + |
| 53 | +```bash |
| 54 | +# Download and extract release |
| 55 | +curl -L https://github.com/damienbutt/emojify-go/releases/latest/download/emojify-go_linux_amd64.tar.gz | tar xz |
| 56 | + |
| 57 | +# Install binary |
| 58 | +sudo mv emojify /usr/local/bin/ |
| 59 | + |
| 60 | +# Install man page |
| 61 | +sudo cp docs/man/emojify.1 /usr/share/man/man1/ |
| 62 | +sudo mandb # Update man database |
| 63 | +``` |
| 64 | + |
| 65 | +## 🏗️ Architecture |
| 66 | + |
| 67 | +### **Simple Design** |
| 68 | + |
| 69 | +- **Single source**: `docs/man/emojify.1` is the only man page file |
| 70 | +- **Package managers**: Handle installation to system directories |
| 71 | +- **No embedding**: Follows standard Go CLI tool patterns |
| 72 | +- **Clean distribution**: Included in release archives |
| 73 | + |
| 74 | +### **How Major Go Tools Handle This** |
| 75 | + |
| 76 | +- **GitHub CLI**: Generates man pages during build, packages handle installation |
| 77 | +- **kubectl**: Uses cobra doc generation, no embedding |
| 78 | +- **Helm**: Standard package manager distribution |
| 79 | + sudo mandb # Update man database |
| 80 | + |
| 81 | +``` |
| 82 | +
|
| 83 | +## 🔧 Implementation Details |
| 84 | +
|
| 85 | +### **Embedded Man Page Code** |
| 86 | +
|
| 87 | +The man page is embedded using a clean, single-source approach: |
| 88 | +
|
| 89 | +**File Structure:** |
| 90 | +
|
| 91 | +``` |
| 92 | + |
| 93 | +docs/man/emojify.1 # ← Single source of truth |
| 94 | +cmd/emojify/emojify.1 -> ../../docs/man/emojify.1 # ← Symbolic link for embed |
| 95 | +man.go # ← Root-level package for embedding |
| 96 | + |
| 97 | +```` |
| 98 | +
|
| 99 | +**Implementation:** |
| 100 | +
|
| 101 | +```go |
| 102 | +// In man.go (root package) |
| 103 | +package man |
| 104 | +
|
| 105 | +import _ "embed" |
| 106 | +
|
| 107 | +//go:embed docs/man/emojify.1 |
| 108 | +var Page []byte |
| 109 | +
|
| 110 | +func Install() error { /* ... */ } |
| 111 | +func Show() error { /* ... */ } |
| 112 | +func Uninstall() error { /* ... */ } |
| 113 | +```` |
| 114 | + |
| 115 | +```go |
| 116 | +// In cmd/emojify/main.go |
| 117 | +import man "github.com/damienbutt/emojify-go" |
| 118 | + |
| 119 | +// Usage in CLI flags |
| 120 | +if c.Bool("install-man") { |
| 121 | + return man.Install() |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +**Key Benefits:** |
| 126 | + |
| 127 | +- **Single source**: Only `docs/man/emojify.1` needs maintenance |
| 128 | +- **Clean embedding**: Root package can access docs/ directory |
| 129 | +- **No duplication**: Symbolic link enables embed without file copying |
| 130 | + |
| 131 | +### **Smart Installation Logic** |
| 132 | + |
| 133 | +1. **Directory Detection**: Finds writable man directories |
| 134 | +2. **Permission Handling**: Prefers user directories over system |
| 135 | +3. **Database Updates**: Automatically runs `mandb`/`makewhatis` |
| 136 | +4. **Cross-platform**: Handles Unix and Windows environments |
| 137 | + |
| 138 | +### **GoReleaser Integration** |
| 139 | + |
| 140 | +Man page included in all release archives: |
| 141 | + |
| 142 | +```yaml |
| 143 | +# .goreleaser.yml |
| 144 | +archives: |
| 145 | + - files: |
| 146 | + - README.md |
| 147 | + - LICENSE.md |
| 148 | + - docs/man/emojify.1 # ← Included in all packages |
| 149 | +``` |
| 150 | +
|
| 151 | +## 🎯 User Experience |
| 152 | +
|
| 153 | +### **Package Manager Users** (Recommended) |
| 154 | +
|
| 155 | +- **Zero effort**: Man page automatically installed |
| 156 | +- **System integration**: Works with standard `man emojify` |
| 157 | +- **Updates**: Man page updated with package |
| 158 | + |
| 159 | +### **Direct Binary Users** |
| 160 | + |
| 161 | +- **Self-service**: `emojify --install-man` for easy setup |
| 162 | +- **Portable**: `emojify --show-man` works anywhere |
| 163 | +- **Clean removal**: `emojify --uninstall-man` for cleanup |
| 164 | + |
| 165 | +### **Developer/CI Users** |
| 166 | + |
| 167 | +- **Embedded access**: Always available without files |
| 168 | +- **Scriptable**: Can pipe output or redirect to files |
| 169 | +- **Universal**: Works in containers, restricted environments |
| 170 | + |
| 171 | +## 🏆 Best Practices |
| 172 | + |
| 173 | +### **For Package Maintainers** |
| 174 | + |
| 175 | +1. Always include man page in packages |
| 176 | +2. Install to standard locations (`/usr/share/man/man1/`) |
| 177 | +3. Update man database after installation |
| 178 | +4. Remove man page during uninstall |
| 179 | + |
| 180 | +### **For Users** |
| 181 | + |
| 182 | +1. Prefer package manager installation when available |
| 183 | +2. Use `--show-man` for quick reference |
| 184 | +3. Use `--install-man` for permanent access |
| 185 | +4. Check `man emojify` works after installation |
| 186 | + |
| 187 | +### **For Developers** |
| 188 | + |
| 189 | +1. Keep embedded man page in sync with CLI |
| 190 | +2. Update version in man page header |
| 191 | +3. Test man page display on all platforms |
| 192 | +4. Include man page in release archives |
| 193 | + |
| 194 | +## 📋 Testing |
| 195 | + |
| 196 | +```bash |
| 197 | +# Test embedded functionality |
| 198 | +emojify --show-man | head -10 |
| 199 | +emojify --install-man |
| 200 | +man emojify |
| 201 | +emojify --uninstall-man |
| 202 | +
|
| 203 | +# Test package installation |
| 204 | +brew install damienbutt/tap/emojify-go |
| 205 | +man emojify |
| 206 | +
|
| 207 | +# Test manual installation |
| 208 | +sudo cp docs/man/emojify.1 /usr/share/man/man1/ |
| 209 | +sudo mandb |
| 210 | +man emojify |
| 211 | +``` |
| 212 | + |
| 213 | +## 🎉 Summary |
| 214 | + |
| 215 | +**Multi-layered approach ensures maximum compatibility:** |
| 216 | + |
| 217 | +1. 📦 **Package managers** handle automatic installation |
| 218 | +2. 🔧 **Embedded support** provides universal access |
| 219 | +3. 📖 **Manual installation** covers edge cases |
| 220 | +4. 🧪 **Comprehensive testing** validates all methods |
| 221 | + |
| 222 | +**Result**: Users get professional Unix documentation regardless of installation method! 🚀 |
0 commit comments