Repository navigation
Migrate the CLI from argh to cw - #6
Merged
Merged
Conversation
Replaces the LGPL `argh` dependency with `cw` (MIT, zero runtime deps). `argh.ArghParser` + `argh.add_commands` + `argh.dispatch` becomes `cw.mk_parser(COMMANDS, prog="lookbook")` + `cw.run(parser)`; `prog` was already pinned, so it stays pinned and the `python -m lookbook` and console -script surfaces remain byte-identical to each other, as before. `cw.run` returns the exit code rather than exiting, so `main()` returns it and the `__main__` guard raises `SystemExit(main())`. The CLI surface is unchanged. 14 argv vectors were recorded from the argh implementation before the edit and replayed against cw: all identical under `--strict-help`, on CPython 3.10 and 3.12 alike. 13 of them are committed as tests/cli_goldens/lookbook.json (the `list-recipes` real-output case is left out: it reads YAML profiles from the user's app data folder). Closes #5 Claude-Session: https://claude.ai/code/session_01K6LB3AwUmKDxaFNZ2NqPGr
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.
Closes #5
Swaps the LGPL
arghdependency forcw(MIT, zero runtime dependencies).The change
progwas already pinned, so it stays pinned — thepython -m lookbookandconsole-script surfaces remain byte-identical to each other, as they were.
cw.runreturns the exit code where argh exited by itself, somain()returns it (the console-script shim does
sys.exit(main())) and the__main__guard raises
SystemExit(main()).pyproject.toml:argh>=0.30→cw>=0.1.1,<0.2. README's file-map line updated.--helpdiff: empty14 argv vectors were recorded from the argh implementation with
cw.testing.characterizebefore any edit — the top-level--helpand-h,all five subcommand
--helps, the no-argument case, three non-zero-exit cases,and the real output of
list-pluginsandlist-recipes. Replayed against cw:--strict-help--strict-helpcompares the full--helpbody, not just exit codes and theusage line. Nothing moved: not the subcommand table, not the docstring-derived
descriptions, not the inferred short flags, not the
nargs='*'rendering of theSequence[str]parameters, and not argh's quirk where--scorerand--selectorboth lose their
-sshort flag to the collision between them.The committed test replays non-strictly, because CPython itself rewrites
argparse's option column between versions and this repo's matrix spans several.
Separately verified that CPython 3.10 and 3.12 render this CLI's shapes
identically, and that published
cw0.1.4 (what CI will resolve) renders themidentically to the source tree — so the strict result above is what CI exercises.
What is now pinned
tests/test_cli_surface.py(7 tests) +tests/cli_goldens/lookbook.json:returnand theraise SystemExitmakes 4 of these tests fail while all 159 pre-existingtests still pass. That is the failure mode invisible to every other test.
argparse with a required subparser does not have.
COMMANDSmatches what the help text advertises.One case is deliberately not in the golden:
list-recipes's real outputreads YAML profiles out of the user's app data folder, so a committed recording
would assert a property of the recording machine.
Tests
159 passed, 3 skippedbefore,166 passed, 3 skippedafter.ruff checkclean.