From 9e54d4cca1c7959d5d5bc00d345e8499fbcdfdcb Mon Sep 17 00:00:00 2001 From: New Future Date: Mon, 14 Jun 2021 12:20:46 +0000 Subject: [PATCH] doc(readme): update config --- README.md | 6 ++++++ util/config.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff77b32f..bae23957 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,12 @@ ## 详细配置 +所有字段可通过三种方式进行配置 + +1. 命令行参数 `ddns --key=value` (`ddns -h` 查看详情),优先级最高 +2. JSON配置文件(值为null认为是有效值,会覆盖环境变量的设置,如果没有对应的key则会尝试试用环境变量) +3. 环境变量DDNS_前缀加上key 全大写或者全小写 (`${ddns_key}` 或 `${DDNS_KEY}`) +
config.json 配置文件 diff --git a/util/config.py b/util/config.py index 7362148b..959c2742 100644 --- a/util/config.py +++ b/util/config.py @@ -55,9 +55,9 @@ def init_config(description, doc, version): __cli_args = parser.parse_args() is_configfile_optional = get_config("token") or get_config("id") - config_file = get_config("config"); + config_file = get_config("config") if not is_configfile_optional or config_file is not None: - __load_config(config_file or "config.json", is_configfile_optional) + __load_config(config_file or "config.json", is_configfile_optional) __cli_args.config = config_file or "config.json"