Fix #433: accept Classic delete --workbook Name syntax - #451
Open
jacalata wants to merge 2 commits into
Open
Conversation
tabcmd Classic invokes delete as `tabcmd delete --workbook "Name"` where --workbook takes the target name as its value. tabcmd 2 shipped `tabcmd delete "Name" --workbook` (name positional, flag is a type selector). This is a breaking CLI difference for anyone running Classic scripts unchanged. Accept both forms: - Positional name stays optional (nargs="?"). - --workbook/--datasource take an optional value (nargs="?"). Bare form still means True (tabcmd 2 syntax); with a value, the value is the target name (Classic syntax). - In run_command, resolve which form supplied the name and normalize args.workbook/args.datasource to True. Emit the same "requires workbook or datasource" error when neither form supplied a name. Mutual exclusion between --workbook and --datasource still holds. Fixes #433.
Covers gaps flagged in fresh-eyes review: - `-w` / `-d` short flags on Classic form - Ambiguous "positional Name + --workbook FlagValue" -- parser accepts both; run_command normalization discards flag value - Bare `--workbook` with no value (parses because nargs="?" const=True) - Classic form + -r project combined The run_command normalization itself (`isinstance(args.workbook, str) -> args.name = args.workbook; args.workbook = True`) is not covered here; tracked in the follow-up run_command coverage issue. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 #433.
Motivation
tabcmd Classic invokes delete as
tabcmd delete --workbook "Name"where
--workbookcarries the target name as its value. tabcmd 2shipped
tabcmd delete "Name" --workbook(name positional, flag astype selector). This is a breaking CLI difference for anyone running
Classic scripts against tabcmd 2. Verified against Classic 2025.1 on
main-windows.tsi.lan.
Behavior change
For users: both forms now work.
nameis now optional (nargs="?").--workbook/--datasourcetake an optional value (nargs="?").Bare form still means
True(tabcmd 2 syntax); with a value, thevalue is the target name (Classic syntax).
run_commandresolves which form supplied the name and normalizesargs.workbook/args.datasourcetoTrue.--workbookand--datasourcestill holds.tabcmd delete Name --workbook OtherName), the positional wins and the flagvalue is silently discarded. Not ideal; could be tightened to an
explicit error in a follow-up.
Test plan
tests/parsers/test_parser_delete.py— 11 tests covering: bothforms, short flags (
-w/-d), mutual exclusion, empty parse,positional+flag-value conflict, bare
--workbookwith no value,Classic form combined with
-rproject flagdisposable workbooks, deleted via all three combinations (tabcmd 2
form, tabcmd 2 with Classic-form flag, Classic 2025.1), same outcome
run_commandnormalization not covered here; tracked in Test coverage gap: run_command logic in the recent parity sweep is untested #457🤖 Generated with Claude Code