fix(cli): set --app and --app-dir as eager parameters#4341
Merged
provinzkraut merged 3 commits intolitestar-org:mainfrom Sep 29, 2025
Merged
fix(cli): set --app and --app-dir as eager parameters#4341provinzkraut merged 3 commits intolitestar-org:mainfrom
--app and --app-dir as eager parameters#4341provinzkraut merged 3 commits intolitestar-org:mainfrom
Conversation
9fcf12b to
09fe04a
Compare
63ffd89 to
a996ae2
Compare
a996ae2 to
ec30aac
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4341 +/- ##
==========================================
- Coverage 97.93% 97.93% -0.01%
==========================================
Files 321 321
Lines 15658 15647 -11
Branches 1733 1733
==========================================
- Hits 15335 15324 -11
Misses 185 185
Partials 138 138 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ctx.params instead of opts--app and --app-dir as eager parameters
|
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4341 |
provinzkraut
approved these changes
Sep 29, 2025
|
|
||
| @click.group(cls=LitestarExtensionGroup, context_settings={"help_option_names": ["-h", "--help"]}) | ||
| @click.option("--app", "app_path", help="Module path to a Litestar application") | ||
| @click.option("--app", "app_path", help="Module path to a Litestar application", is_eager=True) |
Member
There was a problem hiding this comment.
This is a nice solution! Didn't even know this flag existed :)
provinzkraut
pushed a commit
that referenced
this pull request
Sep 29, 2025
(cherry picked from commit c4e0337)
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.
Description
Closes
Fixes #4331
Summary
The problem was in the option value processing. It was expected that the method
parse_argswould cache the values ofapp_pathandapp_dirto use them as default values whenLitestarEnvwas created. Unfortunately,parser.parse_args(list(args))doesn't involve option machinery processing (e.g., type validation and casting), so it returns raw values (strings).This PR solves it by making the
app_pathandapp_diroptions eager, so they are always processed before the--helpoption and are available viactx.params.References
Test plan
test_help_option_with_app_dirtest to verify correct CLI behavior when using--app-dirand--helpoptions together