Feat/core stability#11
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves interactive runtime stability and CLI UX by making parameter casting errors user-friendly, aligning enum validation/completion with actual parsing behavior, and implementing graceful-then-forced Ctrl-C shutdown semantics across the prompt runtime.
Changes:
- Convert raw casting failures (typed + enum) into readable
ValueErrormessages and add a specific hint for mistakenname=valueusage on positional enum parameters. - Align completion behavior with parsing by limiting
name=valuevalue suggestions to keyword parameters and hardening value-splitting. - Add shared shutdown escalation (
BasePrompter.request_shutdown) and integrate SIGINT/prompt interrupt handling inPrompter, with new regression tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/cmdcraft/base.py |
Adds shutdown state + graceful/forced shutdown API; improves unknown-command handling in interpret(). |
src/cmdcraft/prompter.py |
Installs SIGINT handler, exits active prompt cleanly, and unifies runtime interrupt handling. |
src/cmdcraft/parameter.py |
Tightens runtime casting logic and returns readable ValueError messages for invalid typed/enum values. |
src/cmdcraft/command.py |
Detects and reports mistaken positional enum assignment syntax (a=A) with a corrective hint. |
src/cmdcraft/completer.py |
Restricts value completions to keyword params and improves splitting to match parsing behavior. |
test/test_base.py |
Adds regression tests for unknown command output, shutdown escalation, and positional enum hinting. |
test/test_prompter.py |
Adds regression tests for SIGINT behavior and prompt/runtime interrupt handling. |
test/test_completer.py |
Adds regression tests ensuring only keyword parameters get name=value completions. |
test/test_parameter.py |
Updates/extends casting tests, including exact enum error message assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+40
| future = getattr(app, "future", None) | ||
| return app.is_running and future is not None and not future.done() |
Comment on lines
135
to
139
| await self.help() | ||
| return | ||
| await cmd.eval(*input.tokens[1:]) | ||
| except TypeError as e: | ||
| await self.help(cmd) |
Comment on lines
54
to
55
| with pytest.raises(Exception): | ||
| assert par.cast("ARG") |
Weinsen
force-pushed
the
feat/core-stability
branch
2 times, most recently
from
May 17, 2026 17:14
743d29a to
523a62e
Compare
Weinsen
force-pushed
the
feat/core-stability
branch
from
May 17, 2026 17:20
523a62e to
2947025
Compare
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.
Summary
Improve runtime stability for interactive prompts and align enum completion and validation with actual command parsing.
User-facing and developer-facing impact:
name=valuecompletionsa=Afor a positional enum now returns a specific correction hintWhat Changed
Parameter.cast()so invalid typed and enum values raise readableValueErrormessagesCommand.eval()to detect mistaken positional enum assignment syntax and suggest the correct positional formBasePrompterType of Change
Validation
pytest -qpython examples/dynamic_options.pywait 60keeps running after the first Ctrl-C, then exits with status130and no traceback on the second Ctrl-C./tools/lint.sh --changednot run./tools/test.sh -qnot run./tools/docs.shnot runpython -m buildnot runNotes for Reviewers
BasePrompter.request_shutdown(), whilePrompterowns only theprompt_toolkitandSIGINTintegrationPrompter.run()was flattened so prompt and command interrupts share one runtime interrupt path instead of duplicatedexcept KeyboardInterruptbranchesname=valuesuggestions