mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-29 04:35:54 -04:00
Load command defaults from settings
This commit is contained in:
parent
d91f3477a8
commit
e89cc6d590
@ -7,6 +7,7 @@ import typing as t
|
|||||||
from click.testing import Result
|
from click.testing import Result
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from toot import App, User, config, __version__
|
from toot import App, User, config, __version__
|
||||||
|
from toot.settings import load_settings
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
import typing_extensions as te
|
import typing_extensions as te
|
||||||
@ -31,6 +32,13 @@ def get_default_visibility() -> str:
|
|||||||
return os.getenv("TOOT_POST_VISIBILITY", "public")
|
return os.getenv("TOOT_POST_VISIBILITY", "public")
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_map():
|
||||||
|
settings = load_settings()
|
||||||
|
common = settings.get("common", {})
|
||||||
|
commands = settings.get("commands", {})
|
||||||
|
return {**common, **commands}
|
||||||
|
|
||||||
|
|
||||||
# Tweak the Click context
|
# Tweak the Click context
|
||||||
# https://click.palletsprojects.com/en/8.1.x/api/#context
|
# https://click.palletsprojects.com/en/8.1.x/api/#context
|
||||||
CONTEXT = dict(
|
CONTEXT = dict(
|
||||||
@ -42,6 +50,8 @@ CONTEXT = dict(
|
|||||||
max_content_width=100,
|
max_content_width=100,
|
||||||
# Always show default values for options
|
# Always show default values for options
|
||||||
show_default=True,
|
show_default=True,
|
||||||
|
# Load command defaults from settings
|
||||||
|
default_map=get_default_map(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user