# Justfile for mail2couch project # Builds both Go and Rust implementations with distinct binary names # Default recipe default: build # Build both implementations build: build-go build-rust # Build Go implementation as mail2couch-go build-go: @echo "Building Go implementation..." cd go && go build -o mail2couch-go . @echo "✅ Built: go/mail2couch-go" # Build Rust implementation as mail2couch-rs build-rust: @echo "Building Rust implementation..." cd rust && cargo build --release @echo "✅ Built: rust/target/release/mail2couch-rs" # Build optimized release versions build-release: build-go-release build-rust-release # Build optimized Go release build-go-release: @echo "Building optimized Go release..." cd go && go build -ldflags="-s -w" -o mail2couch-go . @echo "✅ Built optimized: go/mail2couch-go" # Build optimized Rust release (already built with --release above) build-rust-release: build-rust # Install binaries to ~/bin (user-local installation) install: build-release @echo "Installing binaries to ~/bin..." mkdir -p ~/bin cp go/mail2couch-go ~/bin/ cp rust/target/release/mail2couch-rs ~/bin/ chmod +x ~/bin/mail2couch-go chmod +x ~/bin/mail2couch-rs @echo "✅ Installed mail2couch-go and mail2couch-rs to ~/bin" @echo "💡 Make sure ~/bin is in your PATH" # Install binaries to /usr/local/bin (system-wide installation, requires sudo) system-install: build-release @echo "Installing binaries to /usr/local/bin..." sudo cp go/mail2couch-go /usr/local/bin/ sudo cp rust/target/release/mail2couch-rs /usr/local/bin/ sudo chmod +x /usr/local/bin/mail2couch-go sudo chmod +x /usr/local/bin/mail2couch-rs @echo "✅ Installed mail2couch-go and mail2couch-rs to /usr/local/bin" # Uninstall binaries from ~/bin uninstall: @echo "Uninstalling binaries from ~/bin..." rm -f ~/bin/mail2couch-go rm -f ~/bin/mail2couch-rs @echo "✅ Uninstalled mail2couch-go and mail2couch-rs from ~/bin" # Uninstall binaries from /usr/local/bin (requires sudo) system-uninstall: @echo "Uninstalling binaries from /usr/local/bin..." sudo rm -f /usr/local/bin/mail2couch-go sudo rm -f /usr/local/bin/mail2couch-rs @echo "✅ Uninstalled mail2couch-go and mail2couch-rs from /usr/local/bin" # Run tests for both implementations test: test-go test-rust # Test Go implementation test-go: @echo "Running Go tests..." cd go && go test ./... # Test Rust implementation test-rust: @echo "Running Rust tests..." cd rust && cargo test # Clean build artifacts clean: @echo "Cleaning build artifacts..." cd go && rm -f mail2couch-go mail2couch cd rust && cargo clean @echo "✅ Cleaned build artifacts" # Check code formatting and linting check: check-go check-rust # Check Go code check-go: @echo "Checking Go code..." cd go && go fmt ./... cd go && go vet ./... # Check Rust code check-rust: @echo "Checking Rust code..." cd rust && cargo fmt --check cd rust && cargo clippy -- -D warnings # Fix code formatting fmt: fmt-go fmt-rust # Format Go code fmt-go: @echo "Formatting Go code..." cd go && go fmt ./... # Format Rust code fmt-rust: @echo "Formatting Rust code..." cd rust && cargo fmt # Development convenience - build and test Go version dev-go: build-go ./go/mail2couch-go --help # Development convenience - build and test Rust version dev-rust: build-rust ./rust/target/release/mail2couch-rs --help # Show binary sizes sizes: build @echo "Binary sizes:" @ls -lh go/mail2couch-go rust/target/release/mail2couch-rs | awk '{print $5 "\t" $9}' # Run both binaries with --version to compare versions: build @echo "Go version:" @./go/mail2couch-go --help | head -1 @echo "" @echo "Rust version:" @./rust/target/release/mail2couch-rs --version # Clean and rebuild everything rebuild: clean build # Systemd service management # Install systemd user service files install-services: @echo "Installing systemd user service files..." mkdir -p ~/.config/systemd/user cp systemd/*.service ~/.config/systemd/user/ cp systemd/*.timer ~/.config/systemd/user/ systemctl --user daemon-reload @echo "✅ Installed systemd user services and timers" @echo "💡 Enable with: systemctl --user enable mail2couch-{go,rs}.service" @echo "💡 Enable timers with: systemctl --user enable mail2couch-{go,rs}.timer" # Uninstall systemd user service files uninstall-services: @echo "Uninstalling systemd user service files..." systemctl --user stop mail2couch-go.service mail2couch-rs.service || true systemctl --user stop mail2couch-go.timer mail2couch-rs.timer || true systemctl --user stop mail2couch-go-hourly.timer mail2couch-rs-hourly.timer || true systemctl --user stop mail2couch-go-daily.timer mail2couch-rs-daily.timer || true systemctl --user disable mail2couch-go.service mail2couch-rs.service || true systemctl --user disable mail2couch-go.timer mail2couch-rs.timer || true systemctl --user disable mail2couch-go-hourly.timer mail2couch-rs-hourly.timer || true systemctl --user disable mail2couch-go-daily.timer mail2couch-rs-daily.timer || true rm -f ~/.config/systemd/user/mail2couch-*.service rm -f ~/.config/systemd/user/mail2couch-*.timer systemctl --user daemon-reload @echo "✅ Uninstalled systemd user services and timers" # Show systemd service status service-status: @echo "Service status:" systemctl --user status mail2couch-go.service || true systemctl --user status mail2couch-rs.service || true @echo "" @echo "Timer status:" systemctl --user list-timers mail2couch-* # Enable Go implementation with default 30-minute timer enable-go: systemctl --user enable mail2couch-go.service systemctl --user enable mail2couch-go.timer systemctl --user start mail2couch-go.timer @echo "✅ Enabled Go implementation with 30-minute timer" # Enable Rust implementation with default 30-minute timer enable-rust: systemctl --user enable mail2couch-rs.service systemctl --user enable mail2couch-rs.timer systemctl --user start mail2couch-rs.timer @echo "✅ Enabled Rust implementation with 30-minute timer" # Enable Go implementation with hourly timer enable-go-hourly: systemctl --user enable mail2couch-go.service systemctl --user enable mail2couch-go-hourly.timer systemctl --user start mail2couch-go-hourly.timer @echo "✅ Enabled Go implementation with hourly timer" # Enable Rust implementation with hourly timer enable-rust-hourly: systemctl --user enable mail2couch-rs.service systemctl --user enable mail2couch-rs-hourly.timer systemctl --user start mail2couch-rs-hourly.timer @echo "✅ Enabled Rust implementation with hourly timer" # Enable Go implementation with daily timer enable-go-daily: systemctl --user enable mail2couch-go.service systemctl --user enable mail2couch-go-daily.timer systemctl --user start mail2couch-go-daily.timer @echo "✅ Enabled Go implementation with daily timer" # Enable Rust implementation with daily timer enable-rust-daily: systemctl --user enable mail2couch-rs.service systemctl --user enable mail2couch-rs-daily.timer systemctl --user start mail2couch-rs-daily.timer @echo "✅ Enabled Rust implementation with daily timer" # Disable all timers and services disable-all: systemctl --user stop mail2couch-go.timer mail2couch-rs.timer || true systemctl --user stop mail2couch-go-hourly.timer mail2couch-rs-hourly.timer || true systemctl --user stop mail2couch-go-daily.timer mail2couch-rs-daily.timer || true systemctl --user disable mail2couch-go.timer mail2couch-rs.timer || true systemctl --user disable mail2couch-go-hourly.timer mail2couch-rs-hourly.timer || true systemctl --user disable mail2couch-go-daily.timer mail2couch-rs-daily.timer || true systemctl --user disable mail2couch-go.service mail2couch-rs.service || true @echo "✅ Disabled all timers and services"