RFC for ArgumentCompleter base class
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- powershell
- 领域
- cli
调研方向
首先阅读所引用的 issue #269 以及本 RFC 中提出的 ArgumentCompleter 示例。梳理所请求的通用行为——引用参数、匹配 WordToComplete 以及对结果进行排序——并定义基类 API 和补全语义。当 RFC 为自定义 ArgumentCompleter 确定了设计,并具有一致的补全行为时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
#269
Provide a base class, ArgumentCompleter, to simplify writing custom argument completers
Some common tasks need to be done almost every time a completer is written.
Things like quoting arguments if they contain spaces, matching against WordToComplete, and ensuring that the results are sorted is another such task.
Motivation
As a Developer,
I can use the base class when writing custom argument completers,
so that results are achieved faster, with high quality, and
so that users get a consistent completion experience.
User Experience
using namespace System.Management.Automation;
public class GetCommitCompleter : ArgumentCompleter
{
// override simplified completer
protected override CompletionResultSortKind AddCompletionsFor(string commandName, string parameterName, IDictionary fakeBoundParameters)
{
switch (parameterName)
{
case nameof(GitRebaseCommand.CommitHash):
CompleteGitCommitHash();
break;
}
return CompletionResultSortKind.Sorted;
}
private void CompleteGitCommitHash()
{
var user = GetFakeBoundParameter<string>("User");
foreach(var commit in GitExe.Log())
{
if (user is { } u && commit.User != u){
continue;
}
// use a function to complete if the text or tooltip matches WordToComplete
CompleteMatching(text: commit.Hash, tooltip: $"{commit.User}\r\n{commit.Description}}": CompletionMatch.AnyContainsWithWordToComplete);
}
}
}
- 主要语言
- PowerShell
- 星标
- 468
- 派生
- 143
- 平均合并
- 9 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PowerShell/PowerShell-RFC 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
PowerShell/PowerShell-RFC#404 · 1 条评论 ·
-
PowerShell/PowerShell-RFC#407 · 1 条评论 · 已指派 1 人 ·
-
难度 4/5 3-5 天 新手友好度 35/100
PowerShell/PowerShell-RFC#396 ·
-
难度 5/5 一周以上 新手友好度 20/100
PowerShell/PowerShell-RFC#334 · 2 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
PowerShell/PowerShell-RFC#327 · 28 条评论 · 31 个 reaction ·
查看 PowerShell/PowerShell-RFC 的全部 Issue
相似的 Issue
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/skills#1811 · 1 条评论 ·
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
难度 2/5 1-3 小时 新手友好度 75/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
CachyOS/distribution#587 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
datalayer/mcp-compose#42 ·