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/HappyPayton/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.1.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.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hancock_cli-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a4d2990212409bf9d9fe84bfef365837450827b359828806a1e47f4365ae8203
MD5 efa241bb8ca5c93f0e283c93b64f97d0
BLAKE2b-256 af815469493fbb12362e843dcfda98f410cf8ebc8cf3fd652e912c6444a8df9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hancock_cli-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75d84ba1eeac1ca1da50594ad9dd4d8c52dd65370bef2814244fa94a947618be
MD5 bad527d732777943bf1a3d39b5b518cb
BLAKE2b-256 df4420daeb4ef9a78428a939a8d1c1277faee0e512c1d1db7d213fa47c04ef32

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