Skip to content

Commit 4548379

Browse files
committed
ci: include man page with package builds
1 parent 03f75a1 commit 4548379

File tree

12 files changed

+452
-17
lines changed

12 files changed

+452
-17
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,6 @@ man:
395395
@echo "📖 Generating man page..."
396396
@./docs/man/manage-man.sh generate
397397

398-
# Test man page
399-
.PHONY: test-man
400-
test-man:
401-
@echo "🧪 Testing man page..."
402-
@./docs/man/manage-man.sh test
403-
404398
# Preview man page
405399
.PHONY: preview-man
406400
preview-man:

README.md

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ nix develop github:damienbutt/emojify-go
126126

127127
```bash
128128
# Run directly
129-
echo "Hello :wave: world" | docker run --rm -i ghcr.io/damienbutt/emojify
129+
echo "Hello :wave: world" | docker run --rm -i ghcr.io/damienbutt/emojify-go
130130

131131
# Use as alias
132-
alias emojify='docker run --rm -i ghcr.io/damienbutt/emojify'
132+
alias emojify='docker run --rm -i ghcr.io/damienbutt/emojify-go'
133133
```
134134

135135
### 📥 Direct Download
@@ -138,31 +138,31 @@ Download the latest binary for your platform from the [releases page](https://gi
138138

139139
```bash
140140
# Linux (AMD64)
141-
curl -L https://github.com/damienbutt/emojify/releases/latest/download/emojify_linux_amd64.tar.gz | tar xz
142-
sudo mv emojify /usr/local/bin/
141+
curl -L https://github.com/damienbutt/emojify/releases/latest/download/emojify-go_linux_amd64.tar.gz | tar xz
142+
sudo mv emojify-go /usr/local/bin/emojify
143143

144144
# macOS (ARM64)
145-
curl -L https://github.com/damienbutt/emojify/releases/latest/download/emojify_darwin_arm64.tar.gz | tar xz
146-
sudo mv emojify /usr/local/bin/
145+
curl -L https://github.com/damienbutt/emojify/releases/latest/download/emojify-go_darwin_arm64.tar.gz | tar xz
146+
sudo mv emojify-go /usr/local/bin/emojify
147147

148148
# Windows (AMD64)
149-
curl -L https://github.com/damienbutt/emojify/releases/latest/download/emojify_windows_amd64.zip -o emojify.zip
149+
curl -L https://github.com/damienbutt/emojify/releases/latest/download/emojify-go_windows_amd64.zip -o emojify.zip
150150
unzip emojify.zip
151151
```
152152

153153
### 🛠️ Build from Source
154154

155155
```bash
156-
git clone https://github.com/damienbutt/emojify.git
157-
cd emojify
156+
git clone https://github.com/damienbutt/emojify-go.git
157+
cd emojify-go
158158
make build
159159
./build/emojify "Hello :wave:"
160160
```
161161

162162
### 📥 Go Install
163163

164164
```bash
165-
go install github.com/damienbutt/emojify/cmd/emojify@latest
165+
go install github.com/damienbutt/emojify-go/cmd/emojify@latest
166166
```
167167

168168
## 🚀 Usage
@@ -379,6 +379,45 @@ seq 1 10000 | sed 's/.*/:rocket: Line &/' | time emojify > /dev/null
379379
emojify --list | head -20
380380
```
381381

382+
## 📖 Documentation
383+
384+
### Man Page
385+
386+
Emojify includes a comprehensive Unix manual page that provides detailed documentation about all commands and options.
387+
388+
#### **Access Methods**
389+
390+
```bash
391+
# View embedded man page (works anywhere)
392+
emojify --show-man
393+
394+
# Install man page to system (for `man emojify`)
395+
emojify --install-man
396+
397+
# Use standard man command (after installation)
398+
man emojify
399+
400+
# Remove installed man page
401+
emojify --uninstall-man
402+
```
403+
404+
#### **Package Manager Installation**
405+
406+
When installed via package managers, the man page is automatically available:
407+
408+
```bash
409+
# After installing via Homebrew, AUR, etc.
410+
man emojify
411+
```
412+
413+
**Supported Systems**: macOS, Linux, Windows (WSL/MSYS2/Cygwin)
414+
415+
#### **Documentation**
416+
417+
- 📖 [Man Page Management Guide](docs/MAN_PAGE_MANAGEMENT.md) - Complete documentation setup
418+
- 📦 [Package Management](package/README.md) - Package distribution details
419+
- 🏗️ [Release Setup](docs/RELEASE_SETUP.md) - Release automation configuration
420+
382421
## 🏗️ Development
383422

384423
### Prerequisites
File renamed without changes.

docs/MAN_PAGE_MANAGEMENT.md

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
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

Comments
 (0)