Skip to content

Commit dfdfd33

Browse files
committed
Handle fake CLI parsers
1 parent a4c3671 commit dfdfd33

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

slide2vec/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ def get_args_parser(add_help: bool = True):
1717

1818
def parse_args(argv=None):
1919
parser = get_args_parser(add_help=True)
20-
args, opts = parser.parse_known_args(argv)
21-
args.opts = opts
20+
if hasattr(parser, "parse_known_args"):
21+
args, opts = parser.parse_known_args(argv)
22+
args.opts = opts
23+
else:
24+
args = parser.parse_args(argv)
25+
args.opts = getattr(args, "opts", [])
2226
return args
2327

2428

tasks/lessons.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Lessons Learned
22

3+
## 2026-04-12
4+
5+
- When refactoring CLI parsing to support `parse_known_args()`, keep existing test doubles in mind: if a fake parser only implements `parse_args()`, add a small compatibility fallback instead of forcing every monkeypatch to mirror the full parser API.
6+
37
## 2026-04-10
48

59
- In this environment, never route `apply_patch` through `exec_command`; use the dedicated `apply_patch` tool directly for file edits.

0 commit comments

Comments
 (0)