gyb
Backup and restore Gmail or Google Workspace
TLDR
Estimate the number and the size of all emails on your Gmail account
Backup a Gmail account to a specific directory
Backup only important or starred emails from a Gmail account to the default local folder
Restore from a local folder to a Gmail account
SYNOPSIS
gyb [options...] [input.gyb [output]]
PARAMETERS
-h, --help
Display usage summary and exit
--line-directive PREFIX
Emit #line directives with given prefix (default: empty string)
--define KEY=VALUE
Define global template variable (repeatable)
--lambda NAME=FILE
Load Python lambda function from file (repeatable)
--indexing-depth N
Max recursion depth for indexing (default: 20)
DESCRIPTION
gyb (Generate Your Boilerplate) is a powerful command-line tool for generating code from text templates using embedded Python logic. Developed primarily for Apple's Swift project, it processes input files with special directives like %if, %elif, %else, %for, %end, and Python expressions delimited by %{ %}.
Indentation is preserved intelligently, making it ideal for languages like Swift, C++, or any structured format. Variables can be defined via command-line options, lambdas loaded from files, and #line directives emitted for source mapping during debugging.
Common workflow: gyb template.gyb --define Name=SwiftString > SwiftString.swift. It supports stdin/stdout for piping and generates output directly or to a file. Python exceptions in templates cause immediate failure with stack traces, aiding development. Widely used in LLVM, Clang, and Swift standard library for repetitive code like operator overloads or enum definitions.
CAVEATS
Requires Python 3.x; whitespace/indentation-sensitive; template Python errors halt with traceback; no built-in caching.
KEY DIRECTIVES
%if condition, %for var in iterable, %end; expressions: %{ py_expr %}; comments: %%.
EXAMPLE
gyb --line-directive '' --define Lang=Swift Enum.gyb -o Enum.swift
Template snippet: %for case in cases: % case %{case.name}%: ...
HISTORY
Created ~2015 for Apple's Swift toolchain (utils/gyb.py); evolved for LLVM/Swift stdlib codegen; open-sourced under Apache 2.0.


