migrate autoopts -> getopt + asciidoctor#991
Merged
Merged
Conversation
Signed-off-by: Gabriel Ganne <gabriel.ganne@gmail.com>
This was found when testing the future option parsing rework, but were unrelated to how the options are actualy parsed. This is mostly about how the error paths are handled. - tcpedit_close(&tcpedit) called on initialization failure paths can lead to use-after-free / NULL dereference. Just remove and errx() exit the program. - tcpprep required both -o AND -i options. use || instead of &&. Signed-off-by: Gabriel Ganne <gabriel.ganne@gmail.com>
autogen's autoopts is getting deprecated in major distributions [1]. Also autoopts and libopts are actually the same package, so this removes libopts dependency entirely. This is a proposal to migrate from autoopts to asciidoctor [2] which is packaged by all major distributions and used by projects like wireshark or git which should guarantee that it will be maintained for a long time. The option parsing themselves are written using standard getopt. Note that asciidoctor comes with a ruby dependency. This should only be needed for maintainers, and since this is already packaged by distributions, I believe this is acceptable. The newly written doc files will be put in a dedicated "docs" folder. Interface changes: * save/load opts removed: - 3 cli options removed - explicit test options instead of loading from file * tcpcapinfo: Remove "--more-help" option which does not display more help. "--help" is enough. * tcpliveplay: Unify all the help options into a single "--help" option that displays the most verbose help output. This is small enough. * migrate roff -> asciidoctor for html documentation generation [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1076243 [2] https://github.com/asciidoctor/asciidoctor Assisted-by: Claude Sonnet 4.6, Claude Opus 4.8 Signed-off-by: Gabriel Ganne <gabriel.ganne@gmail.com>
GabrielGanne
force-pushed
the
autoopt-asciidoctor
branch
from
June 16, 2026 06:51
8c63fe2 to
6bf4e3c
Compare
fklassen
pushed a commit
that referenced
this pull request
Jul 16, 2026
Review fixes for the AutoOpts -> getopt_long migration: - tcpreplay-edit: restore the "--endpoints requires --cachefile" constraint (old .def flags-must) which was silently dropped; without cache direction data --endpoints rewrote both flow directions to the same src->dst pair. tcprewrite already enforced this. - configure.ac: fail early on platforms without getopt_long(3) now that the bundled libopts fallback is gone. - common/args.c: rephrase the option-syntax usage sentence that was carried over verbatim from AutoOpts' usage output. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
fklassen
pushed a commit
that referenced
this pull request
Jul 16, 2026
- CHANGELOG: record the AutoOpts/libopts -> getopt_long + asciidoctor migration under Unreleased, flag the --load-opts/--save-opts and help-option removals as breaking, and note the standalone bug fixes that rode along with the PR. - CREDIT: add Gabriel Ganne. - CLAUDE.md: rewrite the Build and CLI-option sections, which described the deleted AutoOpts/.def machinery (out-of-tree configure flags, autogen dependency, libopts/ directory, *_opts.def workflow). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
|
thanks @GabrielGanne for an excellent PR |
Member
fklassen
pushed a commit
that referenced
this pull request
Jul 19, 2026
generate.py regenerates all 14 *_opts.c/h files from the .def sources (--check verifies without writing). End-to-end verification with autogen physically removed from the system: deleting every src/*_opts.c/h and regenerating reproduces them byte-identically (git diff empty), the tree configures and builds, the full 'sudo make test' suite passes, and both regressions that sank PR #991 are confirmed working - --load-opts (via the prep_config test case that #991 broke) and --more-help. README records why man pages are still autogen-only: unlike the parser emitters, which port an algorithm from the libopts we vendor, the man pipeline is ~1900 lines of external Scheme and Perl with no in-tree source of truth. Three options with costs are written up for a maintainer decision. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fklassen
pushed a commit
that referenced
this pull request
Jul 19, 2026
Generates AsciiDoc man-page source directly from the .def IR (descrip/ doc/explain/detail - the same content already driving --help and the option tables), rendered to roff with `asciidoctor -b manpage`. This replaces GNU autogen's man-page pipeline without hand-duplicating any documentation, avoiding the mistake in the reverted PR #991 (which hand-wrote separate .adoc files that could drift from --help). Unlike emit_h.py/emit_c.py this is not byte-oracle-verified: autogen's mdoc pipeline (cmd-doc.tlib + mdoc2man + Mdoc.pm, ~1900 lines of Scheme and Perl) has no in-tree source of truth to port the way optionPrintParagraphs() was ported from the vendored libopts. Rationale is in the emitter's module docstring. check_adoc.py is the validation gate instead: every real option from the .def must appear in the rendered page, asciidoctor must render it, and groff -man -ww must parse the result with zero warnings. All seven tool configurations (including -DTCPREPLAY_EDIT) pass. texi_to_adoc() handles the texinfo subset actually used in the .def corpus: @file/@var -> italic, @samp/@code -> monospace, @table/ @enumerate + @item (both the inline-label and bare-@item-then-@var-on- next-line forms) -> nested AsciiDoc description lists with proper +/ open-block continuation syntax, @example and mid-paragraph indented- line runs -> literal blocks, and texinfo's "- " item-body marker convention stripped rather than rendered as a spurious bullet. Content parity spot-checked against the current autogen-rendered tcpcapinfo.1: same NAME/options/exit-codes/authors/copyright/bugs content, reformatted into proper subsections instead of run-on paragraphs. Known gap: man-doc attribute content (SIGNALS/custom BUGS/SEE ALSO) is not rendered - matching current behavior, since that content turns out absent from the committed autogen-generated pages too (verified by grep). Noted in README.md as a possible follow-up. generate.py now also writes src/*.adoc alongside *_opts.c/h. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Standards checklist:
sudo make testChanges:
Hi, this is a proposal to address issue #895
I have chosen not to follow the way recommended in the issue description (mostly because of personal preferences). This is proposing to remove libopt and autoopt entirely and to use asciidoctor for documentation generation.
This means I'm breaking the current idea of having one true source for both documentation and code. Although I find that idea is intellectually pleasing, it looks to me this is not the way anymore, at least I was not able to find a good replacement that would fit the current need.
I took the liberty of changing some of the interfaces like some removal of
--short-helpand--long-helpin favor of simple--help, and some of the man page section have had their lines moved (eg. short help moved from synopsys to description). I think it's better that way, but I have no strong opinion and can restore them.Other comments:
I have used AI to help generate the
*_args.cand*_args.hfiles.A note on the license: I have chosen to re-write some macros from autoopts to reduce the amount of changes. libopts was LGPLv3/modified-BSD (GPL-compatible) and tcpreplay is GPLv3 so this should be fine.
A note on the choice to add a dependency on asciidoctor. The ruby part is annoying but this is only a problem for the maintainers, the source distribution builds just like before. Also the project looks to be well established (git, wireshark, redhat's openshift ...) and is packaged by all major distributions.
Best regards