Skip to main content

Gmail signature deployment CLI for Google Workspace

Project description

Hancock

Gmail signature deployment CLI for Google Workspace

Deploy signatures to your entire Google Workspace from the terminal. Simple, fast, and secure.

pip install hancock-cli
hancock init
hancock deploy signatures/

✨ Features

  • 🚀 Simple Setup - One command to configure, works with Google service accounts
  • 🎯 Smart Matching - Automatically matches signature files to users by name or email
  • 📊 Beautiful UI - Colored terminal output with progress bars and clear status
  • ✅ Validation - Checks file sizes, formats, and matching before deployment
  • 🔒 Secure - Your credentials stay on your machine, no data sent elsewhere
  • ⚡ Fast - Deploy to entire organization in minutes
  • 💻 Terminal Native - Works great standalone or with Claude Code

🚀 Quick Start

Install

pip install hancock-cli

Setup (5-15 minutes, one time only)

hancock init

This walks you through:

  1. Locating your Google Cloud service account JSON key
  2. Entering your Google Workspace admin email
  3. Validating credentials

Deploy

Create a folder with HTML signature files named to match your users:

signatures/
├── john.smith.html
├── jane-doe.html
└── bob.jones.html

Then deploy:

hancock deploy signatures/

📖 Commands

hancock init

Interactive setup - configure credentials and validate access.

hancock deploy <folder>

Deploy signatures from a folder to matched users.

Options:

  • --dry-run - Show what would be deployed without actually deploying

Example:

hancock deploy signatures/
hancock deploy ~/my-signatures/ --dry-run

hancock preview <email>

Preview the current signature for a user.

Example:

hancock preview john@company.com

hancock validate <folder>

Validate signature files without deploying.

Example:

hancock validate signatures/

hancock config

Show current configuration and status.


🎯 Creating Signatures

File Naming

Name your HTML files to match users:

  • john.smith.htmljohn.smith@company.com
  • jane-doe.htmljane.doe@company.com
  • bobsmith.htmlbob.smith@company.com

Hancock handles:

  • Dots, dashes, underscores
  • Different name orders
  • Case insensitive matching
  • "sig" or "signature" suffixes

Basic Template

<!DOCTYPE html>
<html>
<body>
<table style="font-family: Arial, sans-serif; font-size: 12px;">
  <tr>
    <td>
      <p style="margin: 0; font-weight: bold;">John Smith</p>
      <p style="margin: 5px 0; color: #666;">Software Engineer</p>
      <p style="margin: 0;">
        <a href="mailto:john@company.com">john@company.com</a>
      </p>
    </td>
  </tr>
</table>
</body>
</html>

Images (No External Hosting)

Use base64 encoding to embed images directly:

# Convert image to base64
base64 -i photo.jpg | tr -d '\n'

Then in your HTML:

<img src="data:image/jpeg;base64,YOUR_BASE64_HERE"
     style="width: 80px; height: 80px;" />

Size Limit

Gmail signatures must be under 10KB. Hancock validates this automatically.

Tips to reduce size:

  • Optimize images before base64 encoding
  • Use JPEG instead of PNG for photos
  • Keep HTML simple and minimal

🔐 Service Account Setup

Hancock uses a Google Cloud service account with domain-wide delegation. This is the same approach used by many enterprise tools.

First-Time Setup (15 minutes)

  1. Go to Google Cloud Console

  2. Create a new project (or select existing)

  3. Enable APIs:

    • Admin SDK API
    • Gmail API
  4. Create Service Account:

    • Go to: IAM & Admin → Service Accounts
    • Create service account
    • Download JSON key
  5. Enable Domain-Wide Delegation:

    • Edit service account
    • Enable domain-wide delegation
    • Note the Client ID
  6. Authorize in Google Workspace:

    • Go to Google Workspace Admin Console
    • Security → API Controls → Domain-wide Delegation
    • Add new with Client ID and scopes:
      https://www.googleapis.com/auth/admin.directory.user.readonly
      https://www.googleapis.com/auth/gmail.settings.basic
      
  7. Run Hancock init:

    hancock init
    

Security

Hancock is secure by design:

  • Your credentials stay on your machine
  • No data sent to third parties
  • Standard Google OAuth 2.0
  • Open source - audit the code

Best practices:

  • Keep your service account JSON secure
  • Don't commit credentials to git
  • Review Google Workspace audit logs

💡 Use Cases

  • Company rebrand - Update all signatures at once
  • New hires - Standardize onboarding signatures
  • Legal compliance - Ensure signatures meet requirements
  • Marketing campaigns - Add promotional content
  • Department changes - Update titles and departments

✨ Using with Claude Code

Hancock works great in Claude Code!

Claude can help you:

  • Walk through the Google Cloud setup
  • Find your service account JSON file
  • Troubleshoot configuration issues
  • Create signature HTML files
  • Validate your setup

Just run hancock init in the Claude Code terminal and Claude will guide you through!


🛠 Troubleshooting

"Hancock is not configured yet"

→ Run hancock init to set up credentials

"Authentication failed"

→ Verify domain-wide delegation is enabled → Check OAuth scopes in Workspace Admin Console → Confirm admin email is correct

"No signatures matched to users"

→ Check filename format (use email prefix or full name) → Verify users exist in Google Workspace → Try different separator styles (dots vs dashes)

"File size exceeds limit"

→ Signatures must be under 10KB → Reduce image dimensions → Optimize images before base64 encoding


📦 Installation

From PyPI (recommended)

pip install hancock-cli

From source

git clone https://github.com/yourusername/hancock-cli.git
cd hancock-cli
pip install -e .

Requirements

  • Python 3.7 or higher
  • Google Workspace admin access
  • Google Cloud service account with domain-wide delegation

🔄 Uninstall

pip uninstall hancock-cli

Your configuration file (~/.hancock/config.yaml) will remain. Delete it manually if desired.


📝 License

MIT License - Free to use and distribute


🌟 Why Hancock?

Simple

  • One install command
  • Interactive setup
  • Terminal-native workflow

Powerful

  • Deploy to entire organization
  • Smart filename matching
  • Real-time progress tracking

Secure

  • Standard Google OAuth
  • Credentials stay local
  • Open source

🚀 Get Started

pip install hancock-cli
hancock init

Questions? File an issue on GitHub


Made with ❤️ for Google Workspace administrators

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hancock_cli-1.0.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hancock_cli-1.0.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file hancock_cli-1.0.0.tar.gz.

File metadata

  • Download URL: hancock_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for hancock_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c54aba6b38fc5e1a80d5d4ee5a379fef36a31038652f9f0cfd66a1a7fed3920e
MD5 cae87ba9c5b96f0a6c751db45cb59b45
BLAKE2b-256 acaabc0eb687e10c62a882a500724213a62c177cd4e1e18450db16dce54966e4

See more details on using hashes here.

File details

Details for the file hancock_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hancock_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for hancock_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d112e3e5cc5eb37d7d33b1a44211d32b03133282498953769cce37c2304029a
MD5 327b46eedc0d5698b261236906a27cc1
BLAKE2b-256 2716bf0558129955413afe92a25873684cf8ab5ecaaa7a428959bcc7d5107ad5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page