Skip to content

feat(cli): group the help by task and wrap it - #391

Merged
HuiJun merged 2 commits into
developfrom
feature/grouped-help
Sep 19, 2026
Merged

HuiJun merged 2 commits into
developfrom
feature/grouped-help

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What and why

sysml -help was 463 lines: 84 flags in one alphabetical list, each alias an entry of its own, arguments typed (string, value) rather than named, 21 descriptions over 200 characters unwrapped, and a mistyped flag dumped the whole list after the error. %help had 24 commands under no heading.

The usage.Doc model gains option groups, and the terminal help and the manual page render them from the same table:

type Doc struct { ...; Options []OptionGroup; ... }
type OptionGroup struct { Title string; Options []Option }
type Option struct { Name string; Aliases []string; Arg string }   // usage.Opt("eval", "<expr>", "e")
func (d Doc) CheckOptions(fs *flag.FlagSet) error                    // every flag in exactly one group
func (d Doc) WriteHint(w io.Writer)                                  // synopsis + "Run 'sysml -help' for the options."
  • sysml -help: flags under 14 task headings (General, Evaluating, Checking a model, Running behaviors, Analysis engines, Checking every schedule, Converting and migrating, Compiling natively, Rendering views, Rendering documents, Styling HTML documents, Syncing against a repository, Diagnostics and profiling, Deprecated), spelled once with the shorthand folded in (-e, -eval <expr>, -o, -output <file>, -satisfy[=<name>]), description wrapped in the column beside it. Examples come before the options (Section.BeforeOptions).
  • Descriptions shortened to a line or two; the detail they carried moves into the section on that mode (Checking a model, new Running actions and state machines and Checking every schedule, Analysis engines, Conversion, Rendering a view). The -pdf-* trio and -to sit under Deprecated as "Former name of -doc-…".
  • Misuse: flag.Usage is doc().WriteHint, so a bad flag prints the error, the synopsis and one pointer line on stderr.
  • Man page: each group is an .SS, each option a .BR \-e ", " \-eval " \fIexpr\fP" tag; man/man1/sysml.1 regenerated. sysml-lsp and sysml-grpc declare no groups and render as before.
  • %help: the ungrouped commands come under Session, Settings, Analysis engines and Checking every schedule; descriptions wrap into a 28-column gutter, a signature wider than that takes a line of its own (folded at 72 for %check-bounds), %exit is noted beside %quit. Table entries are written {name: …, group: …} so examples/self_model_test.go's source check still finds them.

Line-width contract unchanged: no help line exceeds 96 columns (options wrap at 78); the help is now 609 lines, all of it grouped and readable. Not in this PR: a short-card -help with -help <topic> / %help <command>, which needs a one-line summary per flag and is a separate change.

How it was verified

  • New: TestGroupedOptionsFoldAliasesAndWrap, TestCheckOptionsFindsStrayFlags (internal/frontend/usage), TestEveryFlagIsInOneOptionGroup (cmd/sysml — fails when a flag is registered without a group), TestHelpTextIsGroupedAndWrapped (internal/frontend/repl — headings, folded alias, signature fold, width).
  • Updated: TestStreamsAndStatus expects -convert <format> in -h and the three-line answer to --nosuchflag; TestPrintUsageStatesTheExperimentalNotice renders against docFlags().
  • go build ./..., go vet ./..., gofmt -l . (empty), go test ./..., make man-check, python3 scripts/changelog.py check, scripts/check-doc-ids.py all pass.
  • By hand: sysml -h, sysml --nosuchflag, man -l man/man1/sysml.1, %help in the REPL.

Checklist

  • make test and make lint pass locally
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (compliance rows need nothing: the census is counted at docs build)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Runtime verification

Revision 91a090d51 exercised through the built CLI, the man pager and the interactive REPL.

CLI help REPL help
CLI task groups and folded aliases REPL task groups and exit alias
Misuse Rendered manual
Three-line misuse answer man page with grouped options
  • All 84 flag spellings appear exactly once across 14 groups; the examples precede the options; descriptions align at column 30 and no line exceeds 96 columns (609 lines).
  • -h and -help give identical stdout, empty stderr, status 0. An unknown flag and a flag missing its argument each give exactly three stderr lines, no stdout, status 2.
  • man -l renders the grouped subsections, -e, -eval expr and -satisfy[=name]; the emitted roff matches the committed page; make man-check and mandoc -T lint are clean.
  • %help shows the nine headings, column-28 descriptions, width ≤ 78, the folded %check-bounds signature and %exit beside %quit; %hlep still suggests %help, tab completion works, %quit and %exit both exit 0.
  • Regression spot-checks: -e/-eval and -v/-version agree; -o/-output write identical Turtle and the round-tripped SysML validates; -pdf-toc and -doc-toc produce identical HTML with a table of contents.

devin-ai-integration Bot and others added 2 commits September 19, 2026 18:32
sysml -help and the manual page list the flags under task headings, each
spelled once with its shorthand folded in and its argument named, with a
description of a line or two; the detail those descriptions carried moves
into the section on that mode, and the -pdf-* spellings sit under
Deprecated. A mistyped flag is answered with the synopsis and a pointer to
-help rather than the whole help. %help groups every REPL command under a
heading and wraps the descriptions, a wide signature on a line of its own.
A flag left out of every group fails a test.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review September 19, 2026 19:04

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun merged commit 54d018a into develop Sep 19, 2026
12 checks passed
@HuiJun
HuiJun deleted the feature/grouped-help branch September 19, 2026 22:53
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