ui

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ui はターミナル UI (TUI) のプロンプト処理を担当します。

Prompter インターフェースを介して上位レイヤから利用されることで、 テストでは fake 実装に差し替え可能です。本番では survey/v2 を用いた SurveyPrompter を利用します。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRepoLookup

func BuildRepoLookup(repos []ghapi.Repository) ([]string, map[string]*ghapi.Repository)

BuildRepoLookup はリポジトリリストから、表示用ラベルの配列と ラベル→リポジトリの逆引きマップを生成します。SurveyPrompter から 切り出した純粋関数で、単体テスト容易性のために公開しています。

func FilterByLabel

func FilterByLabel(filterValue, optValue string, _ int) bool

FilterByLabel は survey.Select の Filter 関数として使う、大文字小文字を無視した部分一致フィルタです。

func FormatRepoLabel

func FormatRepoLabel(r *ghapi.Repository) string

FormatRepoLabel は survey で見やすいラベルを生成します。 公開しているのは単体テストのためです (純粋関数のため副作用なし)。

func ResolveRepoSelection

func ResolveRepoSelection(label string, lookup map[string]*ghapi.Repository) (*ghapi.Repository, error)

ResolveRepoSelection は選択ラベルから対応する Repository を返します。 見つからない場合はエラーを返します。

Types

type Prompter

type Prompter interface {
	// SelectOwner はユーザに Owner (自分 or 組織) を選択させ、選択結果の文字列を返します。
	SelectOwner(owners []string) (string, error)
	// SelectRepository はユーザにリポジトリを選択させ、選択された Repository を返します。
	SelectRepository(repos []ghapi.Repository) (*ghapi.Repository, error)
	// ConfirmOverwrite は対象ディレクトリ上書き確認用のプロンプトです。
	ConfirmOverwrite(path string) (bool, error)
}

Prompter は対話的な選択 UI の契約です。

type SurveyPrompter

type SurveyPrompter struct{}

SurveyPrompter は survey/v2 を用いた Prompter の本番実装です。

func (SurveyPrompter) ConfirmOverwrite

func (SurveyPrompter) ConfirmOverwrite(path string) (bool, error)

ConfirmOverwrite は対象ディレクトリが既に存在する場合に上書き確認を行います。

func (SurveyPrompter) SelectOwner

func (SurveyPrompter) SelectOwner(owners []string) (string, error)

SelectOwner はユーザーに Owner を選択させます。

func (SurveyPrompter) SelectRepository

func (SurveyPrompter) SelectRepository(repos []ghapi.Repository) (*ghapi.Repository, error)

SelectRepository はユーザーにリポジトリを選択させます。 survey.Select の標準のフィルタ機能(タイプして絞り込み)を活用します。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL