feat: improve dde-dconfig CLI with empty appid support and enhanced shell completions - #155
Conversation
shell completions Overhaul the dde-dconfig command-line tool and its shell completions to properly support application-independent configurations (empty appid) and provide context-sensitive, multi-level tab completions for Bash and Zsh. Key changes: 1. Add `availableResourcesForApp()` helper to return both app-specific and generic resources, enabling proper enumeration when appid is empty 2. Rewrite Bash completion script: track command, positionals, and options independently; offer appid/resource/key suggestions based on current context; support `-s` subpath with leading-slash completion only; handle empty appid (`''`) correctly; suppress duplicate options already on the command line 3. Rewrite Zsh completion script: same context-aware logic as Bash; use `_arguments` with `->state` for comprehensive option descriptions; add dynamic resource/key lookups; handle empty appid; support `-s` subpath completion; expose all CLI options per subcommand 4. Fix CLI key and appid parsing: use relative position index based on whether `-a` is set, so positional keys work correctly regardless of how appid is supplied 5. Strip quotes from empty appid arguments passed by completions (`""` and `''`) 6. Add `isDefaultValue` to list of get methods 7. Update documentation with examples for empty appid usage and subpath behavior; fix command name typo in docs 8. Update example script to use correct empty appid command syntax Log: Improved dde-dconfig CLI with full empty appid support and context- aware tab completions for both Bash and Zsh shells. Influence: 1. Test `dde-dconfig list` without arguments - should list all appids 2. Test `dde-dconfig list -a ""` - should list generic resources only 3. Test tab completion after `dde-dconfig list ` - should suggest appids 4. Test tab completion after `dde-dconfig list -a dconfig-example ` - should suggest `-r` 5. Test tab completion after `dde-dconfig get -a "" -r example ` - should suggest keys 6. Test `dde-dconfig get '' -r example key1` - should work like `-a "" -r example -k key1` 7. Test `dde-dconfig get -a dconfig-example -r example -s /runtime/path -k key1` - subpath passed through without validation 8. Test `dde-dconfig get` with `-m` option - should list methods including `isDefaultValue` 9. Verify Bash and Zsh completions produce same suggestions in all scenarios 10. Test with explicitly empty quoted arguments (`""` or `''`) passed by completions 11. Regression: all existing functional tests for `list`, `get`, `set`, `reset`, `watch`, `gui` commands should pass feat: 改进 dde-dconfig CLI 支持空 appid 并增强 shell 补全 对 dde-dconfig 命令行工具及其 shell 补全进行全面重构,以正确支持应用无关 配置(空 appid),并为 Bash 和 Zsh 提供上下文感知的多级 Tab 补全。 主要变更: 1. 添加 `availableResourcesForApp()` 辅助函数,返回应用特定资源和通用资 源的并集,使 appid 为空时也能正确枚举 2. 重写 Bash 补全脚本:独立跟踪命令、位置参数和选项;根据当前上下文提 供 appid/resource/key 建议;支持 `-s` 子路径仅补全起始斜杠;正确处理空 appid(`''`);抑制已在命令行中的重复选项 3. 重写 Zsh 补全脚本:逻辑同 Bash;使用带有 `->state` 的 `_arguments` 提 供全面的选项描述;支持动态 resource/key 查找;处理空 appid;支持 `-s` 子 路径补全;按子命令暴露所有 CLI 选项 4. 修复 CLI key 和 appid 解析:根据是否设置 `-a` 使用相对位置索引,使位 置参数形式的 key 无论 appid 如何提供都能正确工作 5. 去除补全传递的空 appid 参数(`""` 和 `''`)的引号 6. 将 `isDefaultValue` 添加到 get 的方法列表中 7. 更新文档,包含空 appid 使用和子路径行为的示例;修复文档中的命令名称拼 写错误 8. 更新示例脚本,使用正确的空 appid 命令语法 Log: 改进 dde-dconfig CLI,支持完整的空 appid 功能和 Bash/Zsh 上下文感知 的 Tab 补全。 Influence: 1. 测试 `dde-dconfig list` 无参数 - 应列出所有 appid 2. 测试 `dde-dconfig list -a ""` - 应仅列出通用资源 3. 测试 `dde-dconfig list ` 后按 Tab 补全 - 应建议 appid 4. 测试 `dde-dconfig list -a dconfig-example ` 后按 Tab 补全 - 应建 议 `-r` 5. 测试 `dde-dconfig get -a "" -r example ` 后按 Tab 补全 - 应建议 key 6. 测试 `dde-dconfig get '' -r example key1` - 应与 `-a "" -r example -k key1` 等效 7. 测试 `dde-dconfig get -a dconfig-example -r example -s /runtime/path -k key1` - 子路径直接传递,不验证 8. 测试 `dde-dconfig get` 带 `-m` 选项 - 应列出方法,包括 `isDefaultValue` 9. 验证 Bash 和 Zsh 补全在所有场景下给出相同建议 10. 测试补全传递的显式空引用参数(`""` 或 `''`) 11. 回归测试:所有现有的 list、get、set、reset、watch、gui 功能测试应 通过
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
|
Warning
详情 {
"unset": {
"dconfig-center/dde-dconfig/completion/dde-dconfig.bash": {
"a": [
"\t\t\t\t[[ ${COMPREPLY[j]} == \"$i\" ]] && unset 'COMPREPLY[j]'"
]
}
}
} |
|
Note |
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // main.cpp 中 fetchAppid 的逻辑已较为完善,若需进一步明确字面量处理,可增加注释
inline QString fetchAppid() const
{
QString value;
if (parser.isSet(appidOption)) {
value = parser.value(appidOption);
} else if (parser.positionalArguments().size() > 1) {
value = parser.positionalArguments().at(1);
}
// 兼容部分补全引擎保留引号的行为,将显式空引号视为空appid
if (value == QStringLiteral("\"\"") || value == QStringLiteral("''"))
return QString();
return value;
} |
|
[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 |
Overhaul the dde-dconfig command-line tool and its shell completions to
properly support application-independent configurations (empty appid)
and provide context-sensitive, multi-level tab completions for Bash
and Zsh.
Key changes:
availableResourcesForApp()helper to return both app-specificand generic resources, enabling proper enumeration when appid is empty
options independently; offer appid/resource/key suggestions based on
current context; support
-ssubpath with leading-slash completiononly; handle empty appid (
'') correctly; suppress duplicate optionsalready on the command line
_argumentswith->statefor comprehensive option descriptions; adddynamic resource/key lookups; handle empty appid; support
-ssubpathcompletion; expose all CLI options per subcommand
whether
-ais set, so positional keys work correctly regardless of howappid is supplied
""and
'')isDefaultValueto list of get methodsbehavior; fix command name typo in docs
Log: Improved dde-dconfig CLI with full empty appid support and context-
aware tab completions for both Bash and Zsh shells.
Influence:
dde-dconfig listwithout arguments - should list all appidsdde-dconfig list -a ""- should list generic resources onlydde-dconfig list- should suggest appidsdde-dconfig list -a dconfig-example-should suggest
-rdde-dconfig get -a "" -r example-should suggest keys
dde-dconfig get '' -r example key1- should work like-a "" -r example -k key1dde-dconfig get -a dconfig-example -r example -s /runtime/path -k key1- subpath passed through without validationdde-dconfig getwith-moption - should list methodsincluding
isDefaultValuescenarios
""or'') passedby completions
list,get,set,reset,watch,guicommands should passfeat: 改进 dde-dconfig CLI 支持空 appid 并增强 shell 补全
对 dde-dconfig 命令行工具及其 shell 补全进行全面重构,以正确支持应用无关
配置(空 appid),并为 Bash 和 Zsh 提供上下文感知的多级 Tab 补全。
主要变更:
availableResourcesForApp()辅助函数,返回应用特定资源和通用资源的并集,使 appid 为空时也能正确枚举
供 appid/resource/key 建议;支持
-s子路径仅补全起始斜杠;正确处理空appid(
'');抑制已在命令行中的重复选项->state的_arguments提供全面的选项描述;支持动态 resource/key 查找;处理空 appid;支持
-s子路径补全;按子命令暴露所有 CLI 选项
-a使用相对位置索引,使位置参数形式的 key 无论 appid 如何提供都能正确工作
""和'')的引号isDefaultValue添加到 get 的方法列表中写错误
Log: 改进 dde-dconfig CLI,支持完整的空 appid 功能和 Bash/Zsh 上下文感知
的 Tab 补全。
Influence:
dde-dconfig list无参数 - 应列出所有 appiddde-dconfig list -a ""- 应仅列出通用资源dde-dconfig list后按 Tab 补全 - 应建议 appiddde-dconfig list -a dconfig-example后按 Tab 补全 - 应建议
-rdde-dconfig get -a "" -r example后按 Tab 补全 - 应建议 keydde-dconfig get '' -r example key1- 应与-a "" -r example -k key1等效dde-dconfig get -a dconfig-example -r example -s /runtime/path -k key1- 子路径直接传递,不验证dde-dconfig get带-m选项 - 应列出方法,包括isDefaultValue""或'')通过