PowerShell / PowerShell/PowerShell-RFC

RFC for ArgumentCompleter base class

オープン
#270 コメント 0 件 リアクション 4 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
PowerShell
スター
467
フォーク
140
平均マージ
9分
マージ済み PR(30日)
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);
        }
    }
}

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、参照されている issue #269 と、この RFC で提案されている ArgumentCompleter の例を読んでください。要求されている共通の動作(引数の引用、WordToComplete の一致、結果の並べ替え)を検討し、ベースクラスの API と補完のセマンティクスを定義してください。RFC にカスタム ArgumentCompleter の確定した設計と、一貫した補完動作が定まっていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
powershell
領域
cli
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。