Skip to content

Add man page generation from the command-line model#2

Merged
mnadareski merged 2 commits into
SabreTools:mainfrom
gmipf:man-page-output
Jul 1, 2026
Merged

Add man page generation from the command-line model#2
mnadareski merged 2 commits into
SabreTools:mainfrom
gmipf:man-page-output

Conversation

@gmipf

@gmipf gmipf commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Closes #1.

This adds a roff/man page output path built from the existing command-line
model, so a consuming CLI can emit a man page whose content matches --help,
generated from one source instead of a hand-maintained .1.

Following the issue discussion:

  • CommandSet.OutputManPage(ManPageInfo, bool includeVerbose) returns the page
    as a string. An overload OutputManPage(string path, ManPageInfo, bool) writes
    it to a file and calls the string version. ManPageInfo carries the data the
    model does not: name, section, date, version, title, short description, and the
    options heading.
  • A reference feature Features.ManPage mirrors Help and HelpExtended: it
    takes the enclosing CommandSet and writes the page to standard output. It is
    invoked as a man command (e.g. tool man > tool.1) and wired into
    CommandSet.ProcessArgs alongside the other reference features. The command
    name is overridable through the alternate constructor.
  • includeVerbose echoes HelpExtended: when set, each input's detailed
    description is included. It defaults to true for the reference feature.

Per-input rendering lives on UserInput (FormatManPage) so it reuses
FormatFlags(). The flag column stays identical to --help, so the page cannot
drift from the help text. CommandSet builds the document skeleton and
delegates, mirroring how OutputAllHelp delegates to FormatRecursive.

Output is restricted to the portable man(7) macro set. It validates warning-free
under groff -ww -mandoc and under mandoc -T lint. The .TH date is left
blank by default for the packager to stamp; mandoc emits a single "missing date"
warning in that case, which clears once a date is supplied.

Notes:

  • The new source files carry a UTF-8 BOM to match the other source files in the
    repository. The .editorconfig charset = utf-8 and the committed files
    currently disagree repo-wide, which I left untouched.
  • Builds clean across all target frameworks; nine tests were added.

Prepared with AI assistance (Claude Opus 4.8) and reviewed before submission.

Add CommandSet.OutputManPage (string and file overloads), a ManPageInfo
type for document-level metadata, a reference ManPage feature invoked as a
man command, and UserInput.FormatManPage which reuses FormatFlags so the
page cannot drift from --help. Output uses only portable man(7) macros and
validates warning-free under groff and mandoc -T lint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread SabreTools.CommandLine.Test/ManPageTests.cs Outdated
Comment thread SabreTools.CommandLine/Features/ManPage.cs Outdated
Comment thread SabreTools.CommandLine.Test/ManPageTests.cs Outdated
Comment thread SabreTools.CommandLine/CommandSet.cs Outdated
Comment thread SabreTools.CommandLine/ManPageInfo.cs Outdated
Rename the man page API to the single-word "Manpage" spelling throughout
(Manpage feature, ManpageInfo, CommandSet.OutputManpage,
UserInput.FormatManpage) for consistency with the "manpage" convention.

- Drop the redundant null check in OutputManpage; info is non-nullable
  under the enabled nullable context.
- Move the tests that exercise CommandSet.OutputManpage into
  CommandSetTests as a "Manpage Output" region, and relocate the Manpage
  feature test into a path-synced Features subfolder
  (SabreTools.CommandLine.Test.Features). Private test helpers now sit at
  the bottom of their classes.
- Fix the Manpage feature doc example to use the actual "man" command.

Builds clean across all target frameworks; the 235 tests pass and the
generated page still validates warning-free under groff -man -ww and
mandoc -T lint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mnadareski mnadareski merged commit 754aa6b into SabreTools:main Jul 1, 2026
1 check passed
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.

Generate man page output from the command-line model

2 participants