Skip to content

refactor(cli): parse sqb arguments natively - #1096

Merged
kvlonge merged 3 commits into
mainfrom
feat/native-cli-parser
Oct 13, 2026
Merged

kvlonge merged 3 commits into
mainfrom
feat/native-cli-parser

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Why

Phase 3 of the Rust-hosted SQLBuild port (CHI-592), step 1: sqb argument parsing moves from Python argparse to Rust, removing the Python parser definitions.

Changes

  • New argv parser and help/usage formatter in crates/sqlbuild-cli/src/argv/, driven by an embedded command table (command_table.json) that now defines every command and option.
  • Post-parse normalisation ported: dbt passthrough, positional selectors, SQLBUILD_CONCURRENCY default, cursor/scope/test/janitor checks.
  • Binding _native.parse_cli_arguments; parse_cli_invocation is a thin wrapper.
  • Deleted parser.py, parser_arguments.py, sqlbuild_argument_parser.py and the parsing logic in parsing.py/errors.py.
  • Movable Python: 125,499 → 124,254 lines.

Intentional differences (accepted, recorded on CHI-592):

  • Help/usage uses the Python 3.13+ layout on every version; on 3.12 wrapping and choice quoting differ slightly.
  • Help text is no longer coloured on 3.14.
  • Negative-number detection follows 3.13 on all versions.
  • The native extension now loads for --help/--version (~3 ms).

Verification

  • 1,674-case oracle recorded from the old parser: 0 mismatches (exit code, stdout, stderr, parsed values and types) on 3.13 and 3.14, at widths 40–200, with colour, and with SQLBUILD_CONCURRENCY variants.
  • Independent review: table vs old parser definitions action by action, plus 192 extra invocations: no differences.
  • 1,670 CLI unit and integration tests; cargo test -p sqlbuild-cli; make check-ci; hygiene scan.

…output

Move argv parsing, help/usage/error formatting and parse_cli_invocation's
post-parse rules into a Rust argv domain in sqlbuild-cli, driven by an
embedded command table, and expose it through _native.parse_cli_arguments.
Delete the Python argparse parser, its argument helpers and the coded
parser class.
@kvlonge
kvlonge enabled auto-merge (squash) October 13, 2026 05:08
@kvlonge
kvlonge merged commit ab0217e into main Oct 13, 2026
40 checks passed
@kvlonge
kvlonge deleted the feat/native-cli-parser branch October 13, 2026 05:40
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