Skip to content

refactor/3.5d examples - #248

Merged
sf624 merged 1 commit into
refactor/3.5c-gnu-restfrom
refactor/3.5d-examples
Oct 23, 2026
Merged

sf624 merged 1 commit into
refactor/3.5c-gnu-restfrom
refactor/3.5d-examples

Conversation

@sf624

@sf624 sf624 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Refactor step 3.5 (option parsing), layer 2 of 3. Stacked on #247.

Addresses: D2 (rest), D1 (rest)

  • D2: parseOptions (src/examples/textfilters.ts) builds its result from interpret() with the command's dictionary spec; its tables only say which options each simulator follows. Its callers (sort, uniq, cut, tr, head, tail, seq, basename, dirname, wc, grep, read, xargs), sedArgs, perlOptions and xargs's -0/-d check read the parse. Example tables unchanged, with new rows for what is now followed (sort --rev, tr -C, xargs --replace…) and for what is declined as the tools refuse (grep -E -F, seq 1 -w 3).
  • D1: awkInvocation and the yq -o format read the parse too.
  • Fixes found, each against the tool: seq reads options first and a negative number is an operand; tail +2; awk and perl read options only before the program; tr -C; cut -n (test/options-fixes.test.ts). The cat, tac and rev runners pass the input on only without options or files (cat -n numbers the lines; examples-pipeline).

CHANGELOG: the "Examples and dialect checks…" bullet and the prefix bullet are extended. sample.sh dump unchanged.

Left: sed -i on stdin is simulated where GNU sed fails.

Review fixes: yq v4 reads -o=json as pflag does (cobra preset); cat -n f | sort gets no example (the first-stage cat check reads the parse); git log --max-count 2 shows 2 commits (the git log example reads the parse; rows against git); perl -l0 and -0777 take their octal digits (ValueSpec.attachedMatch; rows against perl); the getopt example reads the parse, and getopt reads its own options first, as util-linux does. The tilde rows in branches.test.ts stay: coverage needs them (comment).

Checks: npm test, extract-snippets --check, Node 24 coverage (every line and branch) pass.

🤖 Generated with Claude Code

@sf624
sf624 added this pull request to stack #250 October 23, 2026 11:48
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

…5, D2 rest, D1 rest)

parseOptions (textfilters.ts) builds its result from interpret() with the
dictionary spec; its tables only say which options each simulator follows.
sedArgs, perlOptions, awkInvocation, xargs, read and the yq -o format read
the parse too. Spec fixes found on the way, checked against the tools: seq
(optionsFirst, a negative number ends the options), tail +N, awk and perl
read options only before the program, tr -C, cut -n.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sf624
sf624 force-pushed the refactor/3.5d-examples branch from 4ec58c9 to 1ed7310 Compare October 23, 2026 13:03
@sf624
sf624 merged commit 6502f33 into main Oct 23, 2026
19 checks passed
@sf624
sf624 deleted the refactor/3.5d-examples branch October 23, 2026 13:22

This branch was previously deployed

1 inactive deployment
github-pages — 1ed73100 Deployed Oct 23, 2026 by sf624 via Deploy to GitHub Pages #513
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