Background
crates/bashkit/src/builtins/ls.rs is 3,605 LoC of handwritten flag parsing — the largest single GNU-parity gap in bashkit's coreutils port table. uu_ls's uu_app() is also the largest clap definition in uutils, so this port is the natural pressure test for the codegen tool: if it survives ls, the rest of coreutils is mechanical.
The PR also forces useful upgrades to bashkit-coreutils-port if uu_ls's en-US.ftl uses Fluent placeables or selectors that the current rewriter does not yet handle.
Acceptance criteria
crates/bashkit/src/builtins/generated/ls_args.rs produced by cargo run -p bashkit-coreutils-port -- /tmp/uutils ls <REV>. If codegen aborts with unresolved translate!() for Fluent placeables/selectors, upgrade the codegen tool to handle the cases uu_ls exercises before committing the output.
pub mod ls_args; added to crates/bashkit/src/builtins/generated/mod.rs.
crates/bashkit/src/builtins/ls.rs switches its argument parser to ls_command().try_get_matches_from(...). Existing rendering logic stays put; the change is parser-only at this issue's scope.
- Flags accepted by
uu_ls but not yet implemented by bashkit return an explicit "not yet implemented" error matching the existing tac -b/-r/-s pattern (no silent no-op).
- GNU help layout —
Usage: first — via the same .help_template(...) chain cat.rs and textrev.rs apply.
tests/spec_cases/bash/help-flag.test.sh ls_help continues to pass; ls_version updated if the version line format diverges.
- Spec tests in
tests/spec_cases/bash/ cover: at least three short flags from uu_ls that bashkit previously parsed loosely (e.g. -Q, --quoting-style=, --group-directories-first), one composite scenario, and unknown-flag rejection (with ### bash_diff for the clap-vs-GNU exit-code difference).
coreutils-args-drift.yml picks up ls_args automatically via the existing pub mod ... grep — no workflow edit required.
- Every existing
ls spec test stays green.
- Compiled binary size delta on
cargo build -p bashkit-cli --release is reported in the PR description (the cat/tac POC was +9 KB declared-but-unused; ls is fully wired so a real number is meaningful).
Out of scope
- Implementing every
uu_ls option (--context, --si, --block-size, full coloration). Leave them parser-accepted-with-explicit-error or wire them to existing bashkit logic only when straightforward.
- Vendoring
uucore::quoting-style for --quoting-style semantics — separate question, see the module-vendor mode issue.
Open questions
- Does the codegen tool's
translate!() rewriter need to handle Fluent placeables ({ $count }, { $name }) and selectors that appear in uu_ls's about/help strings? If yes, the port-tool gets a Phase-2 enhancement before this PR can land cleanly.
- The codegen output for
ls is large (hundreds of args). Measure the cost of try_get_matches_from on every ls invocation against the current handwritten parser. Cache ls_command() in a OnceLock if the construction overhead is meaningful.
Related
Background
crates/bashkit/src/builtins/ls.rsis 3,605 LoC of handwritten flag parsing — the largest single GNU-parity gap in bashkit's coreutils port table.uu_ls'suu_app()is also the largest clap definition in uutils, so this port is the natural pressure test for the codegen tool: if it survivesls, the rest of coreutils is mechanical.The PR also forces useful upgrades to
bashkit-coreutils-portifuu_ls'sen-US.ftluses Fluent placeables or selectors that the current rewriter does not yet handle.Acceptance criteria
crates/bashkit/src/builtins/generated/ls_args.rsproduced bycargo run -p bashkit-coreutils-port -- /tmp/uutils ls <REV>. If codegen aborts withunresolved translate!()for Fluent placeables/selectors, upgrade the codegen tool to handle the casesuu_lsexercises before committing the output.pub mod ls_args;added tocrates/bashkit/src/builtins/generated/mod.rs.crates/bashkit/src/builtins/ls.rsswitches its argument parser tols_command().try_get_matches_from(...). Existing rendering logic stays put; the change is parser-only at this issue's scope.uu_lsbut not yet implemented by bashkit return an explicit "not yet implemented" error matching the existingtac -b/-r/-spattern (no silent no-op).Usage:first — via the same.help_template(...)chaincat.rsandtextrev.rsapply.tests/spec_cases/bash/help-flag.test.shls_helpcontinues to pass;ls_versionupdated if the version line format diverges.tests/spec_cases/bash/cover: at least three short flags fromuu_lsthat bashkit previously parsed loosely (e.g.-Q,--quoting-style=,--group-directories-first), one composite scenario, and unknown-flag rejection (with### bash_difffor the clap-vs-GNU exit-code difference).coreutils-args-drift.ymlpicks upls_argsautomatically via the existingpub mod ...grep — no workflow edit required.lsspec test stays green.cargo build -p bashkit-cli --releaseis reported in the PR description (the cat/tac POC was +9 KB declared-but-unused; ls is fully wired so a real number is meaningful).Out of scope
uu_lsoption (--context,--si,--block-size, full coloration). Leave them parser-accepted-with-explicit-error or wire them to existing bashkit logic only when straightforward.uucore::quoting-stylefor--quoting-stylesemantics — separate question, see the module-vendor mode issue.Open questions
translate!()rewriter need to handle Fluent placeables ({ $count },{ $name }) and selectors that appear inuu_ls's about/help strings? If yes, the port-tool gets a Phase-2 enhancement before this PR can land cleanly.lsis large (hundreds of args). Measure the cost oftry_get_matches_fromon everylsinvocation against the current handwritten parser. Cachels_command()in aOnceLockif the construction overhead is meaningful.Related
lsrow once this lands)specs/coreutils-args-port.mdcrates/bashkit/src/builtins/ls.rscrates/bashkit-coreutils-port/