File tree Expand file tree Collapse file tree 4 files changed +27
-11
lines changed
Expand file tree Collapse file tree 4 files changed +27
-11
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # ChangeLog
2+
3+ ## 0.1
4+
5+ ### 0.1.0
6+
7+ - First release.
Original file line number Diff line number Diff line change @@ -50,7 +50,19 @@ TORTOISE_ORM = {
5050Then you can start an interactive shell for TortoiseORM.
5151
5252``` shell
53- tortoise-cli -c examples.TORTOISE_ORM shell
53+ tortoise-cli -c settings.TORTOISE_ORM shell
54+ ```
55+
56+ Or you can set config by set environment variable.
57+
58+ ``` shell
59+ export TORTOISE_ORM=settings.TORTOISE_ORM
60+ ```
61+
62+ Then just run:
63+
64+ ``` shell
65+ tortoise-cli shell
5466```
5567
5668## License
Original file line number Diff line number Diff line change 11import asyncio
2+ import os
23from functools import wraps
4+ from typing import Optional
35
46import click
57from ptpython .repl import embed
@@ -27,11 +29,14 @@ def wrapper(*args, **kwargs):
2729 "-c" ,
2830 "--config" ,
2931 help = "TortoiseORM config dictionary path, like settings.TORTOISE_ORM" ,
30- required = True ,
3132)
3233@click .pass_context
3334@coro
34- async def cli (ctx : click .Context , config : str ):
35+ async def cli (ctx : click .Context , config : Optional [str ]):
36+ if not config :
37+ config = os .getenv ("TORTOISE_ORM" )
38+ if not config :
39+ raise click .UsageError ("You must specify TORTOISE_ORM in option or env" , ctx = ctx )
3540 tortoise_config = utils .get_tortoise_config (ctx , config )
3641 await Tortoise .init (config = tortoise_config )
3742 await Tortoise .generate_schemas (safe = True )
You can’t perform that action at this time.
0 commit comments