Skip to content

feat(MaaPiCli): 重构为基于子命令的 CLI,新增任务配置文件支持与运行进度输出#1346

Open
srdr0p wants to merge 1 commit into
MaaXYZ:mainfrom
srdr0p:main
Open

feat(MaaPiCli): 重构为基于子命令的 CLI,新增任务配置文件支持与运行进度输出#1346
srdr0p wants to merge 1 commit into
MaaXYZ:mainfrom
srdr0p:main

Conversation

@srdr0p
Copy link
Copy Markdown
Contributor

@srdr0p srdr0p commented May 27, 2026

feat(MaaPiCli): 重构 CLI 接口,支持非交互式/脚本化运行

原版 MaaPiCli 只能通过交互式菜单逐步操作,无法用于 CI/CD、
定时任务或脚本自动化场景。本次重构将其改造为标准子命令式 CLI。

新增子命令:

  • generate-config pi:非交互式生成 maa_pi_config.json,
  • run [--task-config <file>]:运行任务,可通过 TOML/JSON
    配置文件指定本次运行的任务列表与选项覆盖,无需重走交互流程
    不带参数时与原来的-d等价。
    --task-config用于临时指定任务,比如临时跑单个任务。此时会复用maa_pi_config.json中的选项
  • list:列出所有可用控制器、任务和选项
    支持 --controller / --resource / --adb-controller 参数
  • generate-config task:生成含默认值的示例任务配置文件(TOML)

其他改进:

  • 新增 ProgressSink,支持三级进度输出(静默/任务/任务+节点)
  • load() 新增 interactive 参数,非交互模式跳过阻塞式 mpause()
  • 引入 CLI11、tomlplusplus 作为参数解析与配置文件依赖

- 用子命令(run / list / generate-config pi|task)替换原有的 -d 标志,提升可用性
  - `run`:运行任务,支持通过 --task-config 指定 TOML/JSON 配置文件覆盖任务列表与选项
  - `list`:列出所有可用控制器、任务和选项
  - `generate-config pi`:非交互式生成 maa_pi_config.json,支持指定控制器/资源/ADB设备过滤
  - `generate-config task`:生成含默认选项值的示例任务配置文件(TOML)
- 新增 TaskConfig 模块:支持解析 TOML/JSON 格式的任务配置文件,并将其 override 到运行时配置
- 新增 ProgressSink 模块:在 Runner 中集成可配置进度输出(0=静默,1=任务级,2=任务+节点)
- 修复 reconfig_adb 返回 std::optional,ADB 设备未找到时提前报错返回而非静默使用原参数
- load() 新增 interactive 参数,非交互模式下跳过 mpause() 阻塞,支持脚本/CI 调用
- 引入 CLI11 和 tomlplusplus 第三方库
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @srdr0p, your pull request is larger than the review limit of 150000 diff characters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant