Skip to content

Add man page generation for trufflehog#4894

Merged
bryanbeverly merged 2 commits into
trufflesecurity:mainfrom
bryanbeverly:add-man-page
Apr 18, 2026
Merged

Add man page generation for trufflehog#4894
bryanbeverly merged 2 commits into
trufflesecurity:mainfrom
bryanbeverly:add-man-page

Conversation

@bryanbeverly

@bryanbeverly bryanbeverly commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a man page for trufflehog and wires it into the build, release, and Homebrew distribution.

The man page is generated from a hidden --generate-man-page flag using an enhanced Kingpin roff template. The auto-generated OPTIONS and COMMANDS sections stay in sync with the CLI definitions in main.go; EXAMPLES, EXIT STATUS, ENVIRONMENT, FILES, BUGS, and SEE ALSO are hand-maintained in manpage.go. The DESCRIPTION and EXAMPLES sections also document the interactive TUI.

What's included

Feature (commit 1)

  • manpage.go — enhanced roff template + --generate-man-page registration
  • main.go — registers the flag; uses the lowercase binary name in usage; defines --concurrency with a static N placeholder and applies the runtime.NumCPU() default at runtime so the generated man page is deterministic
  • Makefilemake man regenerates docs/man/trufflehog.1 locally; test-release updated to GoReleaser v2 flag syntax
  • .goreleaser.ymlbefore hook regenerates the man page with the release version injected via ldflags; release archives explicitly include LICENSE, README.md, and the man page; Homebrew formula installs to man1
  • docs/man/trufflehog.1 — checked-in generated output (shows dev locally; GoReleaser injects the real version at release time)

Maintenance guardrails (commit 2)

  • .github/workflows/lint.ymlman-page-staleness job runs make man on every PR and fails if docs/man/trufflehog.1 is out of date with the current CLI
  • CONTRIBUTING.md — short note pointing contributors at make man when they change flags or subcommands

Test plan

  • make man produces docs/man/trufflehog.1 matching the checked-in copy byte-for-byte
  • man ./docs/man/trufflehog.1 renders cleanly (one expected cosmetic WARNING: missing date from mandoc -T lint)
  • CGO_ENABLED=0 go build . succeeds; --version and --help work as before
  • --generate-man-page is hidden from --help and --help-long
  • make test-release (goreleaser release --clean --skip=publish,sign --snapshot) succeeds and the resulting archives include the man page:
    for f in dist/*.tar.gz; do echo "=== $f ===" && tar tzf "$f"; done
    
  • Generated Homebrew formula at dist/homebrew/trufflehog.rb installs the man page (one man1.install line per platform/arch is expected):
    grep man1 dist/homebrew/trufflehog.rb
    
  • After release: brew install trufflesecurity/trufflehog/trufflehog && man trufflehog

Made with Cursor


Note

Medium Risk
Mostly build/release/CI wiring plus a small behavioral change to --concurrency defaulting when unset/invalid; risk is primarily around packaging/release failures or unexpected concurrency behavior changes.

Overview
Adds a generated trufflehog(1) man page via a hidden --generate-man-page flag (new manpage.go) and checks in the generated output at docs/man/trufflehog.1.

Wires man-page generation into developer workflow and distribution: make man, a CI staleness check job in lint.yml, and GoReleaser hooks/packaging so release archives and the Homebrew formula install docs/man/trufflehog.1.

Makes small CLI tweaks to support deterministic docs generation, including using lowercase app name/help text and moving --concurrency’s defaulting to runtime (while leaving the man page placeholder stable).

Reviewed by Cursor Bugbot for commit 77ac44c. Bugbot is set up for automated code reviews on this repo. Configure here.

@bryanbeverly bryanbeverly requested a review from a team April 16, 2026 23:18
Add a hidden --generate-man-page flag that uses an enhanced Kingpin
template to produce a standards-compliant roff man page. The man page
includes auto-generated OPTIONS and COMMANDS sections (synced with the
CLI definitions), plus hand-maintained EXAMPLES, EXIT STATUS,
ENVIRONMENT, FILES, BUGS, and SEE ALSO sections.

The DESCRIPTION and EXAMPLES sections call out the interactive TUI
that launches when trufflehog is run without a command in a terminal.

To keep the generated output deterministic, the --concurrency flag is
defined with a static "N" placeholder; the runtime.NumCPU() default is
applied at runtime instead of at flag-definition time. The usage line
also uses the lowercase binary name.

Distribution:
- Makefile `man` target to regenerate locally
- GoReleaser before hook to regenerate at release time with the
  correct version injected via ldflags
- Release archives explicitly include LICENSE, README.md, and
  docs/man/trufflehog.1
- Homebrew formula installs the man page to man1

The Makefile `test-release` target is also updated to GoReleaser v2
flag syntax (--skip=publish,sign), which is needed for the snapshot
release to succeed locally without cosign installed.

Made-with: Cursor
Add a CI job that regenerates the man page on every PR and fails if
the checked-in copy at docs/man/trufflehog.1 is out of date with the
current CLI definitions. Document the regeneration workflow in
CONTRIBUTING.md so contributors know to run `make man` and commit
the result when changing flags or subcommands.

Made-with: Cursor

@mcastorina mcastorina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

@bryanbeverly bryanbeverly merged commit 4d2a8ef into trufflesecurity:main Apr 18, 2026
15 checks passed
@bryanbeverly bryanbeverly deleted the add-man-page branch April 18, 2026 22:19
jainlakshya pushed a commit to jainlakshya/trufflehog_revisions that referenced this pull request May 4, 2026
* Add man page generation for trufflehog

Add a hidden --generate-man-page flag that uses an enhanced Kingpin
template to produce a standards-compliant roff man page. The man page
includes auto-generated OPTIONS and COMMANDS sections (synced with the
CLI definitions), plus hand-maintained EXAMPLES, EXIT STATUS,
ENVIRONMENT, FILES, BUGS, and SEE ALSO sections.

The DESCRIPTION and EXAMPLES sections call out the interactive TUI
that launches when trufflehog is run without a command in a terminal.

To keep the generated output deterministic, the --concurrency flag is
defined with a static "N" placeholder; the runtime.NumCPU() default is
applied at runtime instead of at flag-definition time. The usage line
also uses the lowercase binary name.

Distribution:
- Makefile `man` target to regenerate locally
- GoReleaser before hook to regenerate at release time with the
  correct version injected via ldflags
- Release archives explicitly include LICENSE, README.md, and
  docs/man/trufflehog.1
- Homebrew formula installs the man page to man1

The Makefile `test-release` target is also updated to GoReleaser v2
flag syntax (--skip=publish,sign), which is needed for the snapshot
release to succeed locally without cosign installed.

Made-with: Cursor

* Add man page maintenance guardrails

Add a CI job that regenerates the man page on every PR and fails if
the checked-in copy at docs/man/trufflehog.1 is out of date with the
current CLI definitions. Document the regeneration workflow in
CONTRIBUTING.md so contributors know to run `make man` and commit
the result when changing flags or subcommands.

Made-with: Cursor
MuneebUllahKhan222 pushed a commit that referenced this pull request May 29, 2026
* Add man page generation for trufflehog

Add a hidden --generate-man-page flag that uses an enhanced Kingpin
template to produce a standards-compliant roff man page. The man page
includes auto-generated OPTIONS and COMMANDS sections (synced with the
CLI definitions), plus hand-maintained EXAMPLES, EXIT STATUS,
ENVIRONMENT, FILES, BUGS, and SEE ALSO sections.

The DESCRIPTION and EXAMPLES sections call out the interactive TUI
that launches when trufflehog is run without a command in a terminal.

To keep the generated output deterministic, the --concurrency flag is
defined with a static "N" placeholder; the runtime.NumCPU() default is
applied at runtime instead of at flag-definition time. The usage line
also uses the lowercase binary name.

Distribution:
- Makefile `man` target to regenerate locally
- GoReleaser before hook to regenerate at release time with the
  correct version injected via ldflags
- Release archives explicitly include LICENSE, README.md, and
  docs/man/trufflehog.1
- Homebrew formula installs the man page to man1

The Makefile `test-release` target is also updated to GoReleaser v2
flag syntax (--skip=publish,sign), which is needed for the snapshot
release to succeed locally without cosign installed.

Made-with: Cursor

* Add man page maintenance guardrails

Add a CI job that regenerates the man page on every PR and fails if
the checked-in copy at docs/man/trufflehog.1 is out of date with the
current CLI definitions. Document the regeneration workflow in
CONTRIBUTING.md so contributors know to run `make man` and commit
the result when changing flags or subcommands.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants