Skip to content

Commit 46fc095

Browse files
✨ Feature: 添加 use_cwd 配置项 (#34)
Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com>
1 parent 96e9595 commit 46fc095

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

nonebot_plugin_localstore/__init__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,29 @@
3434

3535
APP_NAME = "nonebot2"
3636
BASE_CACHE_DIR = (
37-
user_cache_dir(APP_NAME).resolve()
37+
(
38+
(Path.cwd() / "cache")
39+
if plugin_config.localstore_use_cwd
40+
else user_cache_dir(APP_NAME).resolve()
41+
)
3842
if plugin_config.localstore_cache_dir is None
3943
else plugin_config.localstore_cache_dir.resolve()
4044
)
4145
BASE_CONFIG_DIR = (
42-
user_config_dir(APP_NAME).resolve()
46+
(
47+
(Path.cwd() / "config")
48+
if plugin_config.localstore_use_cwd
49+
else user_config_dir(APP_NAME).resolve()
50+
)
4351
if plugin_config.localstore_config_dir is None
4452
else plugin_config.localstore_config_dir.resolve()
4553
)
4654
BASE_DATA_DIR = (
47-
user_data_dir(APP_NAME).resolve()
55+
(
56+
(Path.cwd() / "data")
57+
if plugin_config.localstore_use_cwd
58+
else user_data_dir(APP_NAME).resolve()
59+
)
4860
if plugin_config.localstore_data_dir is None
4961
else plugin_config.localstore_data_dir.resolve()
5062
)

nonebot_plugin_localstore/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
class Config(BaseModel):
8+
localstore_use_cwd: bool = False
89
localstore_cache_dir: Optional[Path] = None
910
localstore_config_dir: Optional[Path] = None
1011
localstore_data_dir: Optional[Path] = None

0 commit comments

Comments
 (0)