Skip to content

feat(cli): formalize run/build with System.CommandLine and add a diag command group#10

Merged
phil-scott-78 merged 1 commit into
mainfrom
feat/cli-diag-commands
May 29, 2026
Merged

feat(cli): formalize run/build with System.CommandLine and add a diag command group#10
phil-scott-78 merged 1 commit into
mainfrom
feat/cli-diag-commands

Conversation

@phil-scott-78
Copy link
Copy Markdown
Contributor

What

Routes the host's run/build modes through a single System.CommandLine pipeline and adds a read-only diag command group for inspecting a site — built for humans and AI assistants. Every host gets the CLI for free via RunOrBuildAsync; no Program.cs changes anywhere.

Why

We had two implicit modes selected by an args[0] == "build" boolean that was consulted in ~10 gated places. This formalizes them (real --help/--version, validated options, room for more verbs) and exposes tooling so an AI assistant can quickly see the shape of a docs/blog site.

How

  • Pennington.CliPenningtonCli is the single source of run-mode detection (PenningtonRunMode serve/build/diag; IsHeadlessOneShot/WritesOutput/IsHelpOrVersion gate the TestServer swap, logging, and dev overlays). PenningtonBuildMode stays as a back-compat shim. RunOrBuildAsync builds one RootCommand (serve + build + diag) and dispatches via Parse().InvokeAsync(), so --help/--version work at the root and every subcommand.
  • Seven diag subcommands (text output): info, toc, routes, warnings (--full crawls), translation/i18n, frontmatter, llms. Each reuses existing services (NavigationBuilder, IContentService, IAuditCache, OutputGenerationService, Localization/TranslationOptions). No new abstractions — "area" is just the top-level nav node.
  • Build path behavior is unchanged (TestServer, strict front-matter keys, progress logs, exit code). diag and --help/--version keep stdout clean regardless of the host's appsettings.
  • AuditRunner exposes WaitForInitialPassAsync() and is registered as a resolvable singleton so diag reads a complete audit snapshot.
  • Pennington.Tui steps aside for diag as well as build.

Test plan

  • Added PenningtonCli mode-classification + AsciiTreeWriter unit tests; OutputOptions and Tui regressions stay green.
  • Full suite: 877 unit + 51 treesitter + 48 integration, 0 failed (4 pre-existing skips). Integration tests confirm routing serve through the pipeline doesn't disturb WebApplicationFactory.
  • Manual against the docs site: diag info/toc/routes/warnings/frontmatter/llms, build (473 pages, exit 0), --help/--version at root and every subcommand; multi-locale translation against BeyondLocaleExample.

Closes nothing tracked; net-new feature.

… command group

Route the host's run/build modes through a single System.CommandLine pipeline and
add a read-only `diag` command group for inspecting a site (built for humans and AI
assistants). Every host gets the CLI for free via RunOrBuildAsync — no Program.cs
changes.

- Pennington.Cli: PenningtonCli is the single source of run-mode detection
  (PenningtonRunMode serve/build/diag; IsHeadlessOneShot/WritesOutput/IsHelpOrVersion
  gate the TestServer swap, logging, and dev overlays). PenningtonBuildMode is kept as
  a back-compat shim. RunOrBuildAsync builds one RootCommand (serve + build + diag) and
  dispatches via Parse().InvokeAsync(), so --help/--version work at the root and every
  subcommand.
- diag subcommands (text output): info, toc, routes, warnings (--full crawls),
  translation/i18n, frontmatter, llms. Each reuses existing services (NavigationBuilder,
  IContentService, IAuditCache, OutputGenerationService, Localization/TranslationOptions);
  no new abstractions — "area" is the top-level nav node.
- Build path behavior unchanged (TestServer, strict keys, progress logs, exit code).
  diag and --help/--version keep stdout clean regardless of host appsettings.
- AuditRunner: expose WaitForInitialPassAsync() and register as a resolvable singleton
  so diag reads a complete audit snapshot.
- Pennington.Tui steps aside for `diag` as well as `build`.

Tests: add PenningtonCli mode-classification and AsciiTreeWriter tests; OutputOptions and
Tui regressions stay green. Full suite: 877 unit + 51 treesitter + 48 integration, 0 failed.
@phil-scott-78 phil-scott-78 merged commit 2d82005 into main May 29, 2026
5 checks passed
@phil-scott-78 phil-scott-78 deleted the feat/cli-diag-commands branch May 29, 2026 03:40
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.

1 participant