feat: support passing extra launch arguments to applications via -l option#361
Conversation
There was a problem hiding this comment.
Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Replace the -l/--launch-args option with standard '--' separator for passing extra arguments to application Exec commands. Usage: dde-am org.deepin.xxx -- --show -p "wallpaper" Changes: - Extract args after '--' from argv directly in main() - Add setExtraArgs() to Launcher class - Pass extra args via DBus options map (_extraArgs) - Server appends extra args to command list before execution - Remove wordexp dependency from client side feat(dde-am): 使用 -- 分隔符传递额外启动参数 用标准的 '--' 分隔符替代 -l/--launch-args 选项, 传递额外参数给应用程序的 Exec 命令。 用法: dde-am org.deepin.xxx -- --show -p "wallpaper" Log: 使用 -- 分隔符替代 -l 选项传递额外启动参数 Issue: Fixes linuxdeepin#361 Influence: dde-am 命令行启动应用时,使用 -- 分隔符后的参数作为 Exec 的额外参数,替代原有的 -l 选项方式。
Replace -l/--launch-args with standard '--' separator for passing extra arguments to application Exec commands. Usage: dde-am org.deepin.xxx -- --show -p "wallpaper" 1. Extract args after '--' from argv directly in main() 2. Add setExtraArgs() to Launcher class 3. Pass extra args via DBus options map (_extraArgs) 4. Server appends extra args to command list before execution 5. Remove wordexp dependency from client side feat(dde-am): 使用 -- 分隔符替代 -l 选项传递额外启动参数 1. 用标准 '--' 分隔符替代 -l/--launch-args 选项 2. 从 argv 直接提取 '--' 之后的参数,由 shell 负责引号解析 3. 通过 DBus options map 的 _extraArgs 传递给服务端 4. 服务端在执行命令前将额外参数追加到命令列表 5. 更新帮助文本,展示 -- 分隔符用法 Log: 使用 -- 分隔符替代 -l 选项传递额外启动参数 PMS: BUG-295555 Issue: Fixes linuxdeepin#361 Influence: dde-am 命令行启动应用时,使用 -- 分隔符后的参数作为 Exec 的额外参数,替代原有的 -l 选项方式,避免 wordexp 安全风险。
deepin pr auto review这是一份针对该 Git Diff 的详细代码审查报告。本次修改的主要目的是为 1. 语法与逻辑问题 1: if (!extraArgs.isEmpty()) {
for (int i = 0; i < extraArgs.size() && !arguments.isEmpty(); ++i) {
arguments.removeLast();
}
}风险:这段逻辑建立在一个强假设上:QCommandLineParser 解析出的位置参数末尾,一定恰好是 问题 2: extraArgs.append(QString::fromLocal8Bit(argv[i]));风险:在循环中不断向 2. 代码质量问题 1:手动遍历 bool foundDashDash = false;
for (int i = 1; i < argc; ++i) {
if (qstrcmp(argv[i], "--") == 0) { ... }
}改进建议:这部分逻辑可以提取为一个独立的内联函数或 Lambda,增强代码可读性。另外, 问题 2: void setExtraArgs(const QStringList &args);改进建议:对于资源占用较大的容器类型如 3. 代码性能问题 1: const int estimatedSize = 6 + cmds.size() + task.command.size() + extraArgs.size() + (value.isValid() ? 1 : 0);
newCommands.reserve(estimatedSize);评价:这是一个很好的性能优化点,作者考虑到了新增的 问题 2: 4. 代码安全
newCommands << std::move(extraArgs);
// ...
QProcess process;
// ...
process.start(bin, newCommands);风险分析: 改进后的代码建议1.
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
-l/--launch-argsto dde-am toolsetExtraArgsandparseLaunchArgsin Launcher classwordexpfor proper shell-like argument parsing (supports quotesand escaping)
launcher service
application
arguments with quotes
Log: You can now pass additional arguments to applications when
launching from command line. For example: dde-am org.deepin.dde.control-
center -l '--page="wallpaper"'
Influence:
dde-am org.deepin.calculator -l 'test.txt'dde-am org.deepin.dde.control-center -l '--page="wallpaper"'dde-am org.deepin.calculator -l '-a -b --option=value'work as before
feat: 支持通过-l选项传递额外启动参数给应用程序
-l/--launch-args命令行选项setExtraArgs和parseLaunchArgs方法wordexp进行类shell参数解析(支持引号和转义)Log: 现在可以在命令行启动应用时传递额外参数。例如:dde-am
org.deepin.dde.control-center -l '--page="wallpaper"'
Influence:
dde-am org.deepin.calculator -l 'test.txt'dde-am org.deepin.dde.control-center -l '--page="wallpaper"'dde-am org.deepin.calculator -l '-a -b --option=value'PMS: BUG-295555