cfg
简介
提供全局配置和json配置文件加载功能(相同项替换) pkg.cfg和pkg.json_config配置文件详细说明请看这篇飞书文档:https://leiting.feishu.cn/wiki/OBL9wU2VXiw4b3kiOswcniTPnsh
组件接口
cfg.gs
函数原型 | 函数作用 |
---|---|
void init(mixed cfg_args_or_cfg_path) | 使用指定的配置文件或者配置参数初始化全局配置 |
void init_by_map(map m) | 用指定的数据初始化,可以通过cfg.get_config获取相关配置 |
bool is_inited() | 是不是已经初始化 |
map load(string cfg_path) | 加载配置文件 |
mixed get_config(string path) | 获取全局配置 |
void locate_config(string path) | 调试接口:定位一个配置所在的文件 |
get_option.gs
支持全局选项功能 选项来源有两部分:
- 启动参数--script-args指定的内容
- 通过set_opt动态设置
特别的,如果通过set_opt动态设置的选项存在,则优先获取动态设置的选项
可以通过--script-args指定的全局选项有:
- --config
- --platform
- --exit-when-test-succeed
- --gitlab-cicd
- --gitlab-cicd-local
函数原型 | 函数作用 |
---|---|
mixed get_opt(string opt) | 获取选项值 |
void set_opt(string opt, mixed value) | 设置选项值(选项存在时更新,不存在时新增) |
void dump_opts() | 调试接口: 输出所有选项 |