diff --git a/active_config.nu.example b/active_config.nu.example index 0bfa6f1..805bafe 100644 --- a/active_config.nu.example +++ b/active_config.nu.example @@ -5,7 +5,7 @@ # # > use ../knotfiles/dotfile * # > -# > def-env register [] { +# > def --env register [] { # > declare "example" "example/example.yml" ".config/example.yml" # > } # @@ -17,6 +17,6 @@ use example_module # 注册全部模块 -export def-env register [] { +export def --env register [] { example_module register } diff --git a/example_module/mod.nu b/example_module/mod.nu index f733768..13acf69 100644 --- a/example_module/mod.nu +++ b/example_module/mod.nu @@ -10,7 +10,7 @@ export def module_name [] { } # 声明模块相关的文件 -export def-env declare_files [] { +export def --env declare_files [] { # 普通文件的声明。目标文件位于 ~/.config/example.yml declare (module_name) "example_module/example.yml" ".config/example.yml" @@ -79,7 +79,7 @@ export def post_uninstall [] { } # 注册当前模块 -export def-env register [] { +export def --env register [] { declare_files require_constraints (module_name) (constraints) require_packages (module_name) (dependencies) diff --git a/knotfiles/dotfile/constraint.nu b/knotfiles/dotfile/constraint.nu index 9963df5..d3a6a91 100644 --- a/knotfiles/dotfile/constraint.nu +++ b/knotfiles/dotfile/constraint.nu @@ -7,7 +7,7 @@ use ../log.nu use global_conf.nu # 注册自定义约束 -export def-env register_custom_constraint [ +export def --env register_custom_constraint [ name: string, # 约束名 fn: closure, # 约束检查函数,返回 bool ] { @@ -19,7 +19,7 @@ export def-env register_custom_constraint [ } # 设置模块约束 -export def-env require_constraints [ +export def --env require_constraints [ module: string, constraints: list, ] { diff --git a/knotfiles/dotfile/global_conf.nu b/knotfiles/dotfile/global_conf.nu index 0ddc4bb..bcf4da1 100644 --- a/knotfiles/dotfile/global_conf.nu +++ b/knotfiles/dotfile/global_conf.nu @@ -37,7 +37,7 @@ export def get_config [ } # 设置模块的专有配置 -export def-env set_config [ +export def --env set_config [ module: string, # 模块名 config: string, # 配置项 value # 值 diff --git a/knotfiles/dotfile/hook.nu b/knotfiles/dotfile/hook.nu index 1349ac4..0a2a66f 100644 --- a/knotfiles/dotfile/hook.nu +++ b/knotfiles/dotfile/hook.nu @@ -10,10 +10,10 @@ use global_conf.nu use module.nu [filtered_modules] # 注册钩子 -def-env register_hook [ +def --env register_hook [ hook_type: string, # 钩子类型 module: string, # 模块名称 - hook: closure, # 运行块 + hook: closure, # 运行块 ] { log debug $"注册 ($hook_type): ($module) : ($hook)" @@ -26,27 +26,27 @@ def-env register_hook [ } # 注册模块安装前运行钩子 -export def-env register_pre_install [module: string, hook: closure] { +export def --env register_pre_install [module: string, hook: closure] { register_hook "pre_install" $module $hook } # 注册模块安装后运行钩子 -export def-env register_post_install [module: string, hook: closure] { +export def --env register_post_install [module: string, hook: closure] { register_hook "post_install" $module $hook } # 注册模块卸载前运行钩子 -export def-env register_pre_uninstall [module: string, hook: closure] { +export def --env register_pre_uninstall [module: string, hook: closure] { register_hook "pre_uninstall" $module $hook } # 注册模块卸载后运行钩子 -export def-env register_post_uninstall [module: string, hook: closure] { +export def --env register_post_uninstall [module: string, hook: closure] { register_hook "post_uninstall" $module $hook } # 声明包依赖 -export def-env require_packages [ +export def --env require_packages [ module: string, pkgs: list, ] { diff --git a/knotfiles/dotfile/symlink.nu b/knotfiles/dotfile/symlink.nu index 029f9cc..a240c81 100644 --- a/knotfiles/dotfile/symlink.nu +++ b/knotfiles/dotfile/symlink.nu @@ -19,11 +19,11 @@ def get_base_dir [local: path, dest: path] { } # 声明文件及其目标路径 -export def-env declare [ +export def --env declare [ module: string, # 模块名称 local: any, # 本地路径,以项目根目录为起点的相对路径 dest: string, # 目标路径,以用户家目录为起点的相对路径 - --local-only: bool, # 是否是本地特有的文件。若文件不存在则会自动从 example 创建本地文件 + --local-only, # 是否是本地特有的文件。若文件不存在则会自动从 example 创建本地文件 ] { let type = ($local | describe) let locals = if ($type == "list<string>") { diff --git a/knotfiles/interactive.nu b/knotfiles/interactive.nu index 0f4b941..b2d342c 100644 --- a/knotfiles/interactive.nu +++ b/knotfiles/interactive.nu @@ -2,7 +2,7 @@ # # Copyright (C) 2022 KAAAsS -def-env confirm_loop [ prompt: string, default: string ] { +def --env confirm_loop [ prompt: string, default: string ] { $env.result = if ($env.result == null) { let got = (input $prompt) if ($got == "y" or $got == "n") { diff --git a/knotfiles/pkg.nu b/knotfiles/pkg.nu index ec9bead..dbb1e5c 100644 --- a/knotfiles/pkg.nu +++ b/knotfiles/pkg.nu @@ -17,7 +17,7 @@ export-env { def select_managers [ manager?: string, - --allow-unavailable: bool + --allow-unavailable ] { if ($manager == null) { # 选择第一个可用的包管理器 @@ -181,7 +181,6 @@ export def resolve_manager [ } export def test [] { - use assert # 增加 Mock 管理器 $env.package_managers = [