CLI Reference Template (Man Page Sections)
Command-line reference in man-page order: synopsis, POSIX option syntax, commands, shell completion, environment, files, exit status, JSON output, deprecations
How to use: Use for any command-line tool. Generate the option tables, completion scripts and JSON output schema from the argument parser, then write exit codes, deprecations and examples. The main pitfall is drifting from the tool's --help output or changing exit codes and flags without a deprecation.
Preview
tool-name: Command Reference
Reference page for a command-line tool, organised in the classic manual page sections: NAME, SYNOPSIS, DESCRIPTION, OPTIONS, COMMANDS, ENVIRONMENT, FILES, EXIT STATUS, OUTPUT, EXAMPLES, DIAGNOSTICS, DEPRECATIONS, NOTES and SEE ALSO. Section names, and NAME, SYNOPSIS, DESCRIPTION first and SEE ALSO last, follow the Linux man-pages(7) conventions (man-pages 6.19, February 2026); COMMANDS, OUTPUT, DIAGNOSTICS and DEPRECATIONS are additions common in modern CLI tools, and the middle sections are grouped for CLI readers rather than in the exact man-pages(7) order (which puts EXIT STATUS before ENVIRONMENT and EXAMPLES after NOTES); argument syntax follows the Utility Conventions of POSIX.1-2024 (IEEE Std 1003.1-2024, The Open Group Base Specifications Issue 8, chapter 12); the page is a reference in the sense of the Diátaxis framework. Worked examples use
skyrsync, a fictional file synchronisation tool by the fictional Larkfield Data. Replace every[bracketed]value and every row marked Example.
Document control
| Field | Value |
|---|---|
| Document ID | [DOC-CLI-001] |
| Tool | [tool-name] (Example: skyrsync) |
| Version documented | [2.3.0] |
| Manual section | 1 (user commands) |
| Status | [Draft / In review / Published / Superseded] |
| Owner | [@cli-maintainer] |
| Approvers / reviewers | [@tech-writer], [@product-owner] |
| Last updated | YYYY-MM-DD |
| Classification | [Public] |
| Generated from | [Example: argument parser definitions in cmd/, via skyrsync docs --format md] |
| Related | Configuration Reference (docs/configuration-reference), Migration Guide (docs/migration-guide), Deprecation Notice (docs/deprecation-notice), Changelog (dev/changelog) |
Approvals
| Role | Name | Decision | Date |
|---|---|---|---|
| CLI maintainer | [@name] | [Approved / Changes requested] | YYYY-MM-DD |
| Technical writer | [@name] | [Decision] | YYYY-MM-DD |
Revision history
| Version | Date | Author | Change summary |
|---|---|---|---|
| 0.1 | YYYY-MM-DD | [@name] | First draft |
| 1.0 | YYYY-MM-DD | [@name] | Example: Published for skyrsync 2.3.0; option tables generated from the parser |
| 1.1 | YYYY-MM-DD | [@name] | Example: Added --format ndjson and the deprecation of --del |
NAME
[tool-name] - [synchronise local folders with a remote object store]
Example: skyrsync - synchronise local folders with a remote object store
SYNOPSIS
tool-name [global-options] <command> [command-options] [--] [operand...]
tool-name --version
tool-name --help [command]
tool-name completion bash|zsh|fish|powershell
Notation: [ ] optional, < > a value you supply, ... may repeat, | choose one. This
follows the Utility Argument Syntax of POSIX.1-2024 (section 12.1); angle brackets for
placeholders are a common convention on top of it.
DESCRIPTION
[tool-name] compares a local directory with a remote bucket and transfers the files that differ.
Comparison uses file size and SHA-256 checksum; modification times are ignored unless
--use-mtime is given. Transfers run in parallel and are resumable: an interrupted run continues
from the last completed file when started again.
The tool never deletes remote files unless --delete is given. All network traffic uses HTTPS.
Results are written to standard output; progress, warnings and errors are written to standard
error, so piping the output never mixes in diagnostics. Output is human-readable by default and
machine-readable with --output json (see OUTPUT).
OPTIONS
| Short | Long | Argument | Default | Environment | Description |
|---|---|---|---|---|---|
-c | --config | <path> | $XDG_CONFIG_HOME/tool-name/config.toml | TOOLNAME_CONFIG | Read settings from this file |
--dry-run | none | off | none | Show what would change without changing anything | |
-h | --help | [command] | none | none | Print help for the tool or a command and exit with status 0 |
-j | --jobs | <n> | number of CPUs, maximum 16 | TOOLNAME_JOBS | Number of parallel transfers (1 to 64) |
--no-color | none | colour when stdout is a terminal | NO_COLOR | Disable coloured output | |
--no-input | none | off | TOOLNAME_NO_INPUT | Never prompt; fail with status 2 if input would be needed (use in CI) | |
-o | --output | text, json or ndjson | text | none | Output format (see OUTPUT) |
-p | --profile | <name> | default | TOOLNAME_PROFILE | Use the named credentials profile |
-q | --quiet | none | off | none | Print errors only |
-v | --verbose | none | off | none | Print each file decision; repeat (-vv) for HTTP details |
-V | --version | none | none | none | Print version and exit with status 0 |
Parsing rules, following the POSIX.1-2024 Utility Syntax Guidelines (section 12.2):
- Short options without arguments may be grouped:
-qvequals-q -v(Guideline 5). - An option and its argument are separate words (
-j 8); the joined form-j8and the GNU-style--jobs=8are also accepted (Guideline 6 and its permitted forms). --ends option parsing; every later argument is an operand even if it starts with-(Guideline 10). Use it for paths such as-- -draft.txt.- A lone
-as a source or destination means standard input or standard output (Guideline 13). - Options may appear before or after the command. Long options (
--name) are a GNU convention, not part of the POSIX guidelines; list both forms so readers on either tradition find them.
COMMANDS
| Command | Summary | Since |
|---|---|---|
sync | Make the destination match the source | 1.0 |
ls | List remote objects | 1.0 |
diff | Show differences without transferring | 1.2 |
login | Store credentials for a profile | 1.0 |
config | Read or write configuration values | 2.0 |
completion | Print a shell completion script | 2.1 |
sync
tool-name sync [options] [--] <source> <destination>
Copies new and changed files from source to destination. Either side may be a local path, -
for a tar stream on standard input or output, or a remote URL of the form
remote://bucket/prefix.
| Short | Long | Argument | Default | Description |
|---|---|---|---|---|
--delete | none | off | Delete destination files that do not exist in the source | |
-x | --exclude | <glob> | none | Skip matching paths; may repeat; later patterns win |
--max-bandwidth | <rate> | unlimited | Limit throughput, for example 20MB/s | |
--use-mtime | none | off | Treat a newer modification time as a change | |
--del | none | off | Deprecated alias of --delete (see DEPRECATIONS) |
ls
tool-name ls [--recursive] [--long] <remote-url>
Lists objects under a prefix. --long adds size, checksum and last-modified time.
diff
tool-name diff <source> <destination>
Prints one line per difference: + only in source, - only in destination, ~ content differs.
Exit status is 0 when there are no differences and 4 when differences exist, so scripts can test
the result without parsing output.
login
tool-name login [--profile <name>] [--device-code]
Opens a browser for single sign-on and stores a refresh token in the operating system keychain.
--device-code prints a code to enter on another device, for machines without a browser.
config
tool-name config get <key>
tool-name config set <key> <value>
tool-name config list [--origin]
Reads or writes a value in the configuration file. --origin shows where each effective value
came from. Every key is documented in the Configuration Reference (docs/configuration-reference).
completion
tool-name completion bash|zsh|fish|powershell
Prints a completion script for the named shell to standard output. The script completes commands, options, profile names and remote prefixes. Install it once:
| Shell | Install command |
|---|---|
| bash | tool-name completion bash > ~/.local/share/bash-completion/completions/tool-name |
| zsh | tool-name completion zsh > "${fpath[1]}/_tool-name" |
| fish | tool-name completion fish > ~/.config/fish/completions/tool-name.fish |
| PowerShell | tool-name completion powershell | Out-String | Invoke-Expression (add to your profile) |
Completion scripts are generated from the same parser as this page, so they change when options change. Regenerate them after each upgrade.
ENVIRONMENT
| Variable | Equivalent option | Description |
|---|---|---|
TOOLNAME_CONFIG | --config | Path to the configuration file |
TOOLNAME_JOBS | --jobs | Default parallelism |
TOOLNAME_NO_INPUT | --no-input | Any non-empty value disables prompts |
TOOLNAME_PROFILE | --profile | Default credentials profile |
TOOLNAME_TOKEN | none | Access token; overrides stored credentials (use in CI; never logged) |
NO_COLOR | --no-color | When present and not empty, disables colour (no-color.org convention) |
XDG_CONFIG_HOME, XDG_CACHE_HOME | none | Base directories for FILES on Linux and BSD (XDG Base Directory Specification 0.8) |
HTTPS_PROXY | none | Proxy for all network traffic |
Precedence, highest first: command-line option, environment variable, configuration file, built-in default.
FILES
| Path | Purpose |
|---|---|
$XDG_CONFIG_HOME/tool-name/config.toml (default ~/.config/...) | User configuration. macOS: ~/Library/Application Support/tool-name/config.toml; Windows: %APPDATA%\tool-name\config.toml |
/etc/xdg/tool-name/config.toml | System-wide defaults, read before the user file |
$XDG_CACHE_HOME/tool-name/state.db (default ~/.cache/...) | Resume state for interrupted transfers; safe to delete |
.toolnameignore | Per-directory exclude patterns, one glob per line |
EXIT STATUS
| Code | Meaning |
|---|---|
| 0 | Success; destination matches source |
| 1 | General error |
| 2 | Invalid usage: unknown option, missing argument, or input needed with --no-input |
| 3 | Authentication failed or credentials expired |
| 4 | Partial result: some files failed to transfer, or diff found differences |
| 5 | Network unreachable after retries |
| 130 | Interrupted by the user (Ctrl+C); set by the shell convention 128 + signal number (SIGINT is 2) |
Codes 126 (found but not executable) and 127 (not found) come from the shell, not from the tool, per POSIX.1-2024 XCU section 2.8.2. A status above 128 means the process ended on a signal; the exact value is shell-dependent.
OUTPUT
--output json prints one JSON document when the command finishes; --output ndjson prints one
JSON object per line as events happen. Both are stable: fields are only added in minor releases,
never renamed or removed outside a major release. The JSON Schema (draft 2020-12) is published at
[https://example.com/skyrsync/schema/sync-result.json].
{
"schema": "skyrsync.sync-result/1",
"command": "sync",
"source": "./site",
"destination": "remote://www-assets/site",
"summary": {"uploaded": 12, "deleted": 0, "skipped": 344, "failed": 1, "bytes": 1048576},
"failures": [{"path": "img/hero.png", "code": "permission_denied"}],
"exit_status": 4
}
EXAMPLES
Upload a folder and show what changed:
tool-name sync -v ./site remote://www-assets/site
Preview a mirror that deletes stale remote files, without changing anything:
tool-name sync --delete --dry-run ./site remote://www-assets/site
Download only images, limited to 20 MB/s:
tool-name sync -x '*' -x '!*.png' -x '!*.jpg' --max-bandwidth 20MB/s remote://media/2026 ./media
Use in CI with a token and JSON output, then count failures with jq:
TOOLNAME_TOKEN="$DEPLOY_TOKEN" tool-name sync --no-input -o json ./dist remote://prod-web/ > sync-report.json
jq '.summary.failed' sync-report.json
Sync a file whose name starts with a dash:
tool-name sync -- -draft.txt remote://notes/
DIAGNOSTICS
| Message | Cause | Remedy |
|---|---|---|
error: credentials expired for profile 'default' | Refresh token older than 30 days | Run tool-name login; exit status is 3 |
warning: 3 files skipped (permission denied) | Local files not readable | Check file permissions; exit status is 4 |
error: unknown option '--dle' | Typo in an option name | Use the full option name; exit status is 2 |
warning: --del is deprecated, use --delete | Deprecated alias used | Replace the option before 3.0 |
DEPRECATIONS
| ID | Item | Replacement | Deprecated in | Removal planned | Behaviour now |
|---|---|---|---|---|---|
| CLI-DEP-001 (Example) | --del option | --delete | 2.2 | 3.0 | Works, prints a warning on stderr |
| CLI-DEP-002 (Example) | TOOLNAME_THREADS variable | TOOLNAME_JOBS | 2.0 | 3.0 | Read if TOOLNAME_JOBS is unset, with a warning |
| [CLI-DEP-nnn] | [item] | [replacement] | [x.y] | [x.0] | [behaviour] |
Deprecation warnings go to standard error only, never into JSON output, and are silenced by
--quiet. The Migration Guide (docs/migration-guide) lists the steps for each removal.
NOTES
- Credentials are stored in the operating system keychain, never in the configuration file.
TOOLNAME_TOKENis not written to disk and is masked in-vvoutput. - Paths are compared case-sensitively, including on macOS and Windows; two local files that differ only in case cause exit status 4.
- Symbolic links are followed for files and skipped for directories.
- Report bugs at [https://example.com/skyrsync/issues] with the output of
tool-name --versionand the failing command run with-vv.
SEE ALSO
rsync(1), [tool-name]-config(5), Configuration Reference (docs/configuration-reference),
[Getting started tutorial] (docs/quickstart), [How to deploy a static site with tool-name]
(docs/how-to), Changelog (dev/changelog), Versioning and Release Policy
(dev/versioning-release-policy).
References
| Source | Version checked | Used for |
|---|---|---|
| POSIX.1-2024, IEEE Std 1003.1-2024 (The Open Group Base Specifications Issue 8), XBD chapter 12 Utility Conventions and XCU section 2.8.2 Exit Status for Commands, https://pubs.opengroup.org/onlinepubs/9799919799/ | Checked 2026-10-29 | Synopsis notation, syntax guidelines, shell exit statuses |
| Linux man-pages, man-pages(7), https://man7.org/linux/man-pages/man7/man-pages.7.html | Release 6.19 (2026-02-08), checked 2026-10-29 | Section names and core order |
| Semantic Versioning 2.0.0, https://semver.org/ | 2.0.0, checked 2026-10-29 | Deprecation and breaking change rules |
| XDG Base Directory Specification, https://specifications.freedesktop.org/basedir/latest/ | 0.8 (2021-05-08), checked 2026-10-29 | File locations |
| NO_COLOR, https://no-color.org/ | Checked 2026-10-29 | Colour opt-out variable |
| JSON Schema, https://json-schema.org/specification | 2020-12, checked 2026-10-29 | Output schema |
| Diátaxis, Daniele Procida, https://diataxis.fr/reference/ | Checked 2026-10-29 | Reference form |
Standard and licence note
Based on the conventional section layout of Unix manual pages as described in Linux man-pages(7), the Utility Conventions of POSIX.1-2024 (IEEE Std 1003.1-2024; Copyright The IEEE and The Open Group, freely readable online at pubs.opengroup.org; only section numbers are cited and the guidelines are paraphrased), Semantic Versioning 2.0.0, the XDG Base Directory Specification and the NO_COLOR convention. The reference form follows the Diátaxis framework by Daniele Procida (CC BY-SA 4.0); only its concepts are used and no Diátaxis text is adapted. The text of this template is original. Check the current official versions before relying on this page. Template licence: MIT.
Related templates
Configuration Reference Template
Settings reference: precedence, file format, per-key type, default, range, env var, reload, secrets handling, env var naming, JSON Schema validation, deprecations
Documentation & SupportError Message Reference Template (RFC 9457)
Error catalogue: code scheme, RFC 9457 problem details mapping, writing rules, entries with cause and fix, client handling, governance
Documentation & SupportReference Documentation Template (Diátaxis)
Diátaxis reference page – neutral, consistently structured entries for functions, types, errors and constants