ドキュメンテーション

Man Page & Shell Completions

How to generate a man page for GetWebP CLI and install tab-completion scripts for Bash, Zsh, and Fish.

Man Page & Shell Completions

How to generate a man page for GetWebP CLI and install tab-completion scripts for Bash, Zsh, and Fish.

See also: Commands Reference | Getting Started | README


Table of Contents#


Man Page#

Generation Approach#

The GetWebP man page is maintained as a hand-written roff source file. This gives full control over formatting and avoids build-tool dependencies. The source of truth for flags and behavior is commands.md; the man page mirrors that content in troff format.

An alternative approach is to generate the man page from structured data (e.g., a JSON schema or the CLI's --help output) using tools like marked-man, ronn, or pandoc. For GetWebP, the hand-written approach is preferred because the CLI surface is small (4 commands) and unlikely to change frequently.

Installing the Man Page#

Save the roff source below to a file named getwebp.1, then install it:

# macOS / Linux
sudo mkdir -p /usr/local/share/man/man1
sudo cp getwebp.1 /usr/local/share/man/man1/getwebp.1
sudo gzip -f /usr/local/share/man/man1/getwebp.1
 
# Verify
man getwebp

To uninstall:

sudo rm -f /usr/local/share/man/man1/getwebp.1.gz

Man Page Source#

Save the following as getwebp.1:

.TH GETWEBP 1 "2026-04-02" "getwebp 1.0.1" "GetWebP CLI Manual"
.SH NAME
getwebp \- batch-convert images to WebP format
.SH SYNOPSIS
.B getwebp convert
.RI [ path ]
.RI [ options ]
.br
.B getwebp auth
.I license-key
.RI [ options ]
.br
.B getwebp status
.RI [ options ]
.br
.B getwebp logout
.RI [ options ]
.SH DESCRIPTION
.B getwebp
converts JPG, PNG, BMP, and WebP images to optimized WebP format.
It supports batch conversion of entire directories, parallel processing
(Starter/Pro plans), and structured JSON output for CI/CD pipelines.
.PP
Original files are never modified or deleted.
.SH COMMANDS
.TP
.B convert \fR[\fIpath\fR] [\fIoptions\fR]
Convert one or more images to WebP format. The positional
.I path
argument and the
.B \-i
flag are interchangeable. If both are provided, the positional argument
takes precedence.
.TP
.B auth \fIlicense-key\fR
Activate a license key to unlock Starter or Pro features. Binds the
license to the current device.
.TP
.B status
Display current license info, plan tier, expiry date, and device usage.
.TP
.B logout
Unbind the license from this device, freeing a device slot. Requires
network access.
.SH CONVERT OPTIONS
.TP
.BR \-i ", " \-\-input " " \fIpath\fR
Input file or directory (alternative to positional argument).
.TP
.BR \-o ", " \-\-output " " \fIpath\fR
Output directory for converted files. Defaults to the same directory as
the source.
.TP
.BR \-q ", " \-\-quality " " \fInumber\fR
WebP quality, 1\-\-100. Default: 80.
.TP
.BR \-r ", " \-\-recursive
Recursively process images in subdirectories.
.TP
.B \-\-concurrency " " \fInumber\fR
Number of parallel workers (max 32). Default: CPU cores minus 1.
Starter/Pro plans only; ignored on Free plan.
.TP
.B \-\-dry\-run
Preview which files would be converted without writing any files.
.TP
.B \-\-skip\-existing
Skip conversion if a .webp file already exists at the output path.
.SH LOGOUT OPTIONS
.TP
.BR \-f ", " \-\-force
Skip the interactive confirmation prompt.
.SH GLOBAL OPTIONS
.TP
.BR \-v ", " \-\-version
Print CLI version and exit.
.TP
.B \-\-help
Show help text and exit.
.TP
.B \-\-json
Emit structured JSON output on stdout. Human-readable messages go to
stderr. Available on all commands.
.TP
.B \-\-verbose
Enable verbose output.
.TP
.B \-\-debug
Enable debug output. Implies
.BR \-\-verbose .
.SH EXIT STATUS
.TP
.B 0
All files processed successfully.
.TP
.B 1
General error.
.TP
.B 2
Partial failure (some files failed).
.TP
.B 3
License / auth error.
.TP
.B 4
Network error.
.SH EXAMPLES
Convert a single image:
.PP
.RS
.B getwebp convert photo.png
.RE
.PP
Convert a directory with custom output:
.PP
.RS
.B getwebp convert ./images \-o ./dist/images
.RE
.PP
High quality, skip already-converted files:
.PP
.RS
.B getwebp convert ./images \-q 95 \-\-skip\-existing
.RE
.PP
Recursive scan with 8 parallel workers:
.PP
.RS
.B getwebp convert ./images \-r \-\-concurrency 8
.RE
.PP
JSON output for CI/CD:
.PP
.RS
.B getwebp convert ./images \-\-json
.RE
.PP
Activate a license:
.PP
.RS
.B getwebp auth XXXX\-XXXX\-XXXX\-XXXX
.RE
.PP
Check license status:
.PP
.RS
.B getwebp status \-\-json
.RE
.PP
Logout without confirmation:
.PP
.RS
.B getwebp logout \-\-force
.RE
.SH FREE PLAN LIMITATIONS
Without an activated license: maximum 10 files per run, 3-second delay
between files, and serial processing only (\-\-concurrency is ignored).
.SH SEE ALSO
.UR https://getwebp.com
GetWebP website
.UE ,
.UR https://getwebp.com/pricing
Pricing
.UE
.SH AUTHORS
GetWebP team.

Shell Completions#

Bash Completions#

Save the following as getwebp.bash (or getwebp in your completions directory).

# getwebp bash completion
# Install: copy to /etc/bash_completion.d/getwebp
#   or source from ~/.bashrc
 
_getwebp() {
    local cur prev words cword
    _init_completion || return
 
    local commands="convert auth status logout"
    local global_flags="--version --help --json --verbose --debug"
 
    # Determine which command (if any) has been typed
    local cmd=""
    local i
    for ((i = 1; i < cword; i++)); do
        case "${words[i]}" in
            convert|auth|status|logout)
                cmd="${words[i]}"
                break
                ;;
        esac
    done
 
    # No command yet — complete commands and global flags
    if [[ -z "$cmd" ]]; then
        COMPREPLY=($(compgen -W "$commands $global_flags" -- "$cur"))
        return
    fi
 
    case "$cmd" in
        convert)
            local convert_flags="-i --input -o --output -q --quality -r --recursive --concurrency --dry-run --skip-existing --json --verbose --debug"
            case "$prev" in
                -i|--input|-o|--output)
                    # Complete file/directory paths
                    _filedir
                    return
                    ;;
                -q|--quality)
                    # Suggest common quality values
                    COMPREPLY=($(compgen -W "60 70 75 80 85 90 95 100" -- "$cur"))
                    return
                    ;;
                --concurrency)
                    COMPREPLY=($(compgen -W "1 2 4 8 16 32" -- "$cur"))
                    return
                    ;;
            esac
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($(compgen -W "$convert_flags" -- "$cur"))
            else
                # Positional argument: file/directory path
                _filedir
            fi
            ;;
        auth)
            # auth takes a license key (no completion) and optional flags
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($(compgen -W "--json --verbose --debug" -- "$cur"))
            fi
            ;;
        status)
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($(compgen -W "--json --verbose --debug" -- "$cur"))
            fi
            ;;
        logout)
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($(compgen -W "-f --force --json --verbose --debug" -- "$cur"))
            fi
            ;;
    esac
}
 
complete -F _getwebp getwebp

Install Bash Completions#

# Option A: System-wide (requires root)
sudo cp getwebp.bash /etc/bash_completion.d/getwebp
 
# Option B: Per-user
mkdir -p ~/.local/share/bash-completion/completions
cp getwebp.bash ~/.local/share/bash-completion/completions/getwebp
 
# Option C: Source directly in ~/.bashrc
echo 'source /path/to/getwebp.bash' >> ~/.bashrc

Reload your shell or run source ~/.bashrc for completions to take effect.


Zsh Completions#

Save the following as _getwebp.

#compdef getwebp
 
# getwebp zsh completion
# Install: copy to a directory in your $fpath (e.g., /usr/local/share/zsh/site-functions/)
 
_getwebp() {
    local -a commands
    commands=(
        'convert:Convert images to WebP format'
        'auth:Activate a license key'
        'status:Show license and version info'
        'logout:Unbind license from this device'
    )
 
    local -a global_flags
    global_flags=(
        '(-v --version)'{-v,--version}'[Print CLI version and exit]'
        '--help[Show help text and exit]'
        '--json[Structured JSON output on stdout]'
        '--verbose[Enable verbose output]'
        '--debug[Enable debug output (implies --verbose)]'
    )
 
    _arguments -C \
        '1:command:->command' \
        '*::arg:->args' \
        && return
 
    case "$state" in
        command)
            _describe -t commands 'getwebp command' commands
            _values 'global flags' $global_flags
            ;;
        args)
            case "${words[1]}" in
                convert)
                    _arguments \
                        '1:path:_files' \
                        '(-i --input)'{-i,--input}'[Input file or directory]:path:_files' \
                        '(-o --output)'{-o,--output}'[Output directory]:path:_files -/' \
                        '(-q --quality)'{-q,--quality}'[WebP quality 1-100]:quality:(60 70 75 80 85 90 95 100)' \
                        '(-r --recursive)'{-r,--recursive}'[Recursively process subdirectories]' \
                        '--concurrency[Number of parallel workers (max 32)]:workers:(1 2 4 8 16 32)' \
                        '--dry-run[Preview files without converting]' \
                        '--skip-existing[Skip if .webp already exists]' \
                        '--json[JSON output for CI pipelines]' \
                        '--verbose[Enable verbose output]' \
                        '--debug[Enable debug output]'
                    ;;
                auth)
                    _arguments \
                        '1:license-key:' \
                        '--json[JSON output]' \
                        '--verbose[Enable verbose output]' \
                        '--debug[Enable debug output]'
                    ;;
                status)
                    _arguments \
                        '--json[JSON output]' \
                        '--verbose[Enable verbose output]' \
                        '--debug[Enable debug output]'
                    ;;
                logout)
                    _arguments \
                        '(-f --force)'{-f,--force}'[Skip confirmation prompt]' \
                        '--json[JSON output]' \
                        '--verbose[Enable verbose output]' \
                        '--debug[Enable debug output]'
                    ;;
            esac
            ;;
    esac
}
 
_getwebp "$@"

Install Zsh Completions#

# Option A: System-wide
sudo cp _getwebp /usr/local/share/zsh/site-functions/_getwebp
 
# Option B: Per-user (add custom dir to fpath)
mkdir -p ~/.zsh/completions
cp _getwebp ~/.zsh/completions/_getwebp
 
# Add to ~/.zshrc (before compinit):
#   fpath=(~/.zsh/completions $fpath)
#   autoload -Uz compinit && compinit

After installing, run rm -f ~/.zcompdump && compinit or restart your shell.


Fish Completions#

Save the following as getwebp.fish.

# getwebp fish completion
# Install: copy to ~/.config/fish/completions/getwebp.fish
 
# Disable file completions by default (we enable them per-subcommand)
complete -c getwebp -f
 
# Helper: true when no subcommand has been entered yet
function __getwebp_no_subcommand
    set -l tokens (commandline -opc)
    for t in $tokens[2..]
        switch $t
            case convert auth status logout
                return 1
        end
    end
    return 0
end
 
# Helper: true when the given subcommand is active
function __getwebp_using_subcommand
    set -l tokens (commandline -opc)
    for t in $tokens[2..]
        switch $t
            case $argv[1]
                return 0
        end
    end
    return 1
end
 
# --- Top-level completions ---
complete -c getwebp -n '__getwebp_no_subcommand' -a convert  -d 'Convert images to WebP format'
complete -c getwebp -n '__getwebp_no_subcommand' -a auth     -d 'Activate a license key'
complete -c getwebp -n '__getwebp_no_subcommand' -a status   -d 'Show license and version info'
complete -c getwebp -n '__getwebp_no_subcommand' -a logout   -d 'Unbind license from this device'
complete -c getwebp -n '__getwebp_no_subcommand' -s v -l version  -d 'Print CLI version'
complete -c getwebp -n '__getwebp_no_subcommand' -l help           -d 'Show help text'
complete -c getwebp -n '__getwebp_no_subcommand' -l json           -d 'JSON output'
complete -c getwebp -n '__getwebp_no_subcommand' -l verbose        -d 'Enable verbose output'
complete -c getwebp -n '__getwebp_no_subcommand' -l debug          -d 'Enable debug output'
 
# --- convert ---
complete -c getwebp -n '__getwebp_using_subcommand convert' -s i -l input        -r -F -d 'Input file or directory'
complete -c getwebp -n '__getwebp_using_subcommand convert' -s o -l output       -r -F -d 'Output directory'
complete -c getwebp -n '__getwebp_using_subcommand convert' -s q -l quality      -r -x -a '60 70 75 80 85 90 95 100' -d 'WebP quality 1-100'
complete -c getwebp -n '__getwebp_using_subcommand convert' -s r -l recursive         -d 'Process subdirectories'
complete -c getwebp -n '__getwebp_using_subcommand convert'      -l concurrency  -r -x -a '1 2 4 8 16 32' -d 'Parallel workers (max 32)'
complete -c getwebp -n '__getwebp_using_subcommand convert'      -l dry-run           -d 'Preview without converting'
complete -c getwebp -n '__getwebp_using_subcommand convert'      -l skip-existing     -d 'Skip if .webp exists'
complete -c getwebp -n '__getwebp_using_subcommand convert'      -l json              -d 'JSON output'
complete -c getwebp -n '__getwebp_using_subcommand convert'      -l verbose           -d 'Enable verbose output'
complete -c getwebp -n '__getwebp_using_subcommand convert'      -l debug             -d 'Enable debug output'
# Allow file path completion for positional arg
complete -c getwebp -n '__getwebp_using_subcommand convert' -F
 
# --- auth ---
complete -c getwebp -n '__getwebp_using_subcommand auth' -l json    -d 'JSON output'
complete -c getwebp -n '__getwebp_using_subcommand auth' -l verbose -d 'Enable verbose output'
complete -c getwebp -n '__getwebp_using_subcommand auth' -l debug   -d 'Enable debug output'
 
# --- status ---
complete -c getwebp -n '__getwebp_using_subcommand status' -l json    -d 'JSON output'
complete -c getwebp -n '__getwebp_using_subcommand status' -l verbose -d 'Enable verbose output'
complete -c getwebp -n '__getwebp_using_subcommand status' -l debug   -d 'Enable debug output'
 
# --- logout ---
complete -c getwebp -n '__getwebp_using_subcommand logout' -s f -l force   -d 'Skip confirmation prompt'
complete -c getwebp -n '__getwebp_using_subcommand logout'      -l json    -d 'JSON output'
complete -c getwebp -n '__getwebp_using_subcommand logout'      -l verbose -d 'Enable verbose output'
complete -c getwebp -n '__getwebp_using_subcommand logout'      -l debug   -d 'Enable debug output'

Install Fish Completions#

# Fish loads completions automatically from this directory
cp getwebp.fish ~/.config/fish/completions/getwebp.fish

No restart is needed. Fish picks up new completion files on the next tab press.


Homebrew Formula Integration#

When distributing GetWebP via Homebrew, the formula can install the man page and shell completions automatically. Add the following to the formula's install method:

class Getwebp < Formula
  desc "Batch-convert images to optimized WebP format"
  homepage "https://getwebp.com"
  version "1.0.1"
  license "MIT"
 
  # ... platform-specific url/sha256 blocks ...
 
  def install
    bin.install "getwebp"
 
    # Man page
    man1.install "getwebp.1"
 
    # Shell completions
    bash_completion.install "completions/getwebp.bash" => "getwebp"
    zsh_completion.install  "completions/_getwebp"
    fish_completion.install "completions/getwebp.fish"
  end
 
  test do
    assert_match "getwebp/#{version}", shell_output("#{bin}/getwebp --version")
  end
end

Homebrew provides the helper methods bash_completion, zsh_completion, and fish_completion that install files to the correct directories for each shell. Users who install via brew install getwebp get completions automatically with no manual setup.

Release Checklist#

When cutting a new release, ensure the following files are included in the release tarball or bottle:

FilePurpose
getwebpBinary
getwebp.1Man page (roff source)
completions/getwebp.bashBash completions
completions/_getwebpZsh completions
completions/getwebp.fishFish completions

Verifying Completions Work#

After installing completions for your shell, verify they work:

# Bash / Zsh: type and press Tab
getwebp <TAB>            # Should show: convert  auth  status  logout
getwebp convert -<TAB>   # Should show all convert flags
getwebp convert --q<TAB> # Should complete to --quality
getwebp logout -<TAB>    # Should show: -f  --force  --json  --verbose  --debug
# Fish: type and press Tab
getwebp <TAB>                  # Shows subcommands with descriptions
getwebp convert --concurrency <TAB>  # Shows: 1  2  4  8  16  32

If completions do not appear, check:

  1. Bash: Ensure bash-completion is installed (brew install bash-completion@2 on macOS).
  2. Zsh: Ensure compinit is called in ~/.zshrc and ~/.zcompdump is not stale.
  3. Fish: Ensure the file is in ~/.config/fish/completions/ and the filename matches the command name.