Skip to content

fix(cli): make every help string match what the CLI does (#1796) - #1810

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1796-cli-output-help
Oct 16, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1796-cli-output-help

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Summary

pcapkit-cli's help strings in pcapkit/__main__.py did not match main() and Extractor. Each string was rewritten from probes of the real CLI; behaviour is untouched (an AST comparison with every help= masked is identical).

  • Output: -o described the input file; it now gives the default out, the extension added only with --auto-extension, and the directory meaning under --files.
  • Input and -a: the input help said .pcap is appended; that happens only with --auto-extension, and not for .pcap, .cap or .pcapng names. -a covers the input too.
  • Format: -j, -p and -t each claimed to override all other options. The real order is -f, then -j, then -p, then -t, which is the default; each string now names what beats it. -f lists the accepted formats.
  • The rest: -v, -F, -E, -P/-L, -B and -O now say what they do, and the grammar slips are fixed.
  • Docs: the help block in docs/source/pcapkit/index.rst is regenerated from real --help at COLUMNS=80.
  • Tests: tests/cli/test_main.py pins each corrected claim, including the precedence against main(). The new assertions fail on main's strings. tests/cli, the CLI subprocess tests and tests/project pass.

Closes #1796

@JarryShaw JarryShaw added the fix Pull requests that fix a defect (fix: subject prefix) label Oct 16, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at d3f1f5c76. A Sonnet cross-review and re-check (author: Opus). Each help string was probed against the real CLI in temp dirs: input with and without -a and .pcap/.cap/.pcapng, output with and without -a, and -F. The docs help block matches real --help output, and every new assertion fails on main's strings. tests/cli, the CLI subprocess tests and tests/project pass.

@JarryShaw JarryShaw added the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 16, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 16, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

The rendered-docs proofread (#1103) found more help strings with the same defect: -j, -p and -t each claim to override all other options (-f wins over all three), plus some grammar. A fix round is extending this PR. Fine to merge as is; if it lands first, the rest goes in a follow-up PR.

The CLI help described behaviour the code does not have. -o read "The
name of input pcap file"; the input, -o and -a help said extensions are
always appended, but -a is off by default; -j, -p and -t each claimed to
override all other options, while main() tests -f, then -j, then -p,
then -t; -f claimed every dictdumper format, but the formats are those
Extractor registers, PCAP included. The rest were vague or ungrammatical
("a extraction", "if ... omits", "Indicate if store buffer", `stdin').

- pcapkit/__main__.py: every help string states the real behaviour,
  including the format precedence and default, the engine fallback, where
  -P/-L stop and that third-party engines ignore them, and when -B/-O
  write a buffer file. No behaviour change.
- docs/source/pcapkit/index.rst: the CLI block regenerated from
  `python -m pcapkit --help` at COLUMNS=80.
- tests/cli/test_main.py: pin each corrected help, checking the named
  precedence against what main() forwards; every new assertion fails on
  origin/main.

Closes #1796
@JarryShaw
JarryShaw force-pushed the fix/1796-cli-output-help branch from d3f1f5c to 44a7738 Compare October 16, 2026 03:07
@JarryShaw JarryShaw changed the title fix(cli): make the input, output and auto-extension help match the code (#1796) fix(cli): make every help string match what the CLI does (#1796) Oct 16, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 44a7738dd. A Sonnet re-check (author: Opus) probed every help string against the real CLI, including option precedence with -f, -j, -p and -t alone and combined. main() is unchanged (AST with help= masked), and the docs block equals real --help. The new tests fail on main's strings and against a branch-swap mutant. tests/cli, the CLI subprocess tests and tests/project pass.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 89.60% (unit tier, Python 3.15, 44a7738dd, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 18862 954 2368 868 91.06%
pcapkit/corekit 2462 69 780 35 96.55%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2915 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17197 224 4580 189 98.09%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 512 2 158 4 99.10%
pcapkit/vendor 4417 2342 1010 157 43.38%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 71df8b1 into main Oct 16, 2026
53 checks passed
@JarryShaw
JarryShaw deleted the fix/1796-cli-output-help branch October 16, 2026 13:10
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 16, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(cli): the -o/--output help text describes the input file

1 participant