PowerShell / PowerShell/PowerShell-RFC
RFC for ArgumentCompleter base class
还没有人认领这个 Issue。
- 主要语言
- PowerShell
- 星标
- 467
- 派生
- 140
- 平均合并
- 9 分钟
- 30 天内合并 PR
- 1
描述
#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);
}
}
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先阅读所引用的 issue #269 以及本 RFC 中提出的 ArgumentCompleter 示例。梳理所请求的通用行为——引用参数、匹配 WordToComplete 以及对结果进行排序——并定义基类 API 和补全语义。当 RFC 为自定义 ArgumentCompleter 确定了设计,并具有一致的补全行为时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell
- 领域
- cli
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100