Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 80 additions & 31 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,89 @@ export default defineConfig({
head: [
['link', { rel: 'icon', href: '/Sharprompt/icon.png' }]
],
themeConfig: {
logo: '/icon.png',
nav: [
{ text: 'Guide', link: '/getting-started' },
{ text: 'NuGet', link: 'https://www.nuget.org/packages/Sharprompt/' }
],
sidebar: [
{
text: 'Introduction',
items: [
{ text: 'Getting Started', link: '/getting-started' }
rewrites: {
'en/:rest*': ':rest*'
},
locales: {
root: {
label: 'English',
lang: 'en',
themeConfig: {
nav: [
{ text: 'Guide', link: '/getting-started' },
{ text: 'NuGet', link: 'https://www.nuget.org/packages/Sharprompt/' }
],
sidebar: [
{
text: 'Introduction',
items: [
{ text: 'Getting Started', link: '/getting-started' }
]
},
{
text: 'Prompt Types',
items: [
{ text: 'Input', link: '/prompt-types/input' },
{ text: 'Confirm', link: '/prompt-types/confirm' },
{ text: 'Password', link: '/prompt-types/password' },
{ text: 'Select', link: '/prompt-types/select' },
{ text: 'MultiSelect', link: '/prompt-types/multi-select' },
{ text: 'List', link: '/prompt-types/list' },
{ text: 'Bind', link: '/prompt-types/bind' }
]
},
{
text: 'Reference',
items: [
{ text: 'Validators', link: '/validators' },
{ text: 'Configuration', link: '/configuration' },
{ text: 'Advanced Features', link: '/advanced' }
]
}
]
},
{
text: 'Prompt Types',
items: [
{ text: 'Input', link: '/prompt-types/input' },
{ text: 'Confirm', link: '/prompt-types/confirm' },
{ text: 'Password', link: '/prompt-types/password' },
{ text: 'Select', link: '/prompt-types/select' },
{ text: 'MultiSelect', link: '/prompt-types/multi-select' },
{ text: 'List', link: '/prompt-types/list' },
{ text: 'Bind', link: '/prompt-types/bind' }
]
},
{
text: 'Reference',
items: [
{ text: 'Validators', link: '/validators' },
{ text: 'Configuration', link: '/configuration' },
{ text: 'Advanced Features', link: '/advanced' }
}
},
ja: {
label: '日本語',
lang: 'ja',
themeConfig: {
nav: [
{ text: 'ガイド', link: '/ja/getting-started' },
{ text: 'NuGet', link: 'https://www.nuget.org/packages/Sharprompt/' }
],
sidebar: [
{
text: 'Introduction',
items: [
{ text: 'Getting Started', link: '/ja/getting-started' }
]
Comment on lines +62 to +66
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Japanese locale sidebar config, the section titles are still English (e.g., “Introduction”, “Prompt Types”, “Reference”). If the goal is a fully Japanese experience, these text labels should be translated as well for consistency with the Japanese nav.

Copilot uses AI. Check for mistakes.
},
{
text: 'Prompt Types',
items: [
{ text: 'Input', link: '/ja/prompt-types/input' },
{ text: 'Confirm', link: '/ja/prompt-types/confirm' },
{ text: 'Password', link: '/ja/prompt-types/password' },
{ text: 'Select', link: '/ja/prompt-types/select' },
{ text: 'MultiSelect', link: '/ja/prompt-types/multi-select' },
{ text: 'List', link: '/ja/prompt-types/list' },
{ text: 'Bind', link: '/ja/prompt-types/bind' }
]
},
{
text: 'Reference',
items: [
{ text: 'Validators', link: '/ja/validators' },
{ text: 'Configuration', link: '/ja/configuration' },
{ text: 'Advanced Features', link: '/ja/advanced' }
]
}
]
}
],
}
},
themeConfig: {
logo: '/icon.png',
socialLinks: [
{ icon: 'github', link: 'https://github.com/shibayan/Sharprompt' }
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
85 changes: 85 additions & 0 deletions docs/ja/advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 高度な機能

## Enum 型のサポート

`Select` や `MultiSelect` で Enum 型を使用すると、Enum の値から自動的に項目が生成されます。`[Display]` 属性を使って表示名をカスタマイズできます:

```csharp
using System.ComponentModel.DataAnnotations;

public enum MyEnum
{
[Display(Name = "First value")]
First,
[Display(Name = "Second value")]
Second,
[Display(Name = "Third value")]
Third
}

var value = Prompt.Select<MyEnum>("Select enum value");
Console.WriteLine($"You selected {value}");
```

`MultiSelect` の場合:

```csharp
var values = Prompt.MultiSelect<MyEnum>("Select enum values");
Console.WriteLine($"You picked {string.Join(", ", values)}");
```

## Unicode サポート

Sharprompt はマルチバイト文字と絵文字をサポートしています。最良の結果を得るには、出力エンコーディングを UTF-8 に設定してください:

```csharp
Console.OutputEncoding = Encoding.UTF8;

var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");
```

## Fluent インターフェース

すべてのプロンプトタイプは `Sharprompt.Fluent` 名前空間を通じて Fluent インターフェースをサポートしています:

```csharp
using Sharprompt.Fluent;

var city = Prompt.Select<string>(o => o.WithMessage("Select your city")
.WithItems(new[] { "Seattle", "London", "Tokyo" })
.WithDefaultValue("Seattle"));
```

Fluent API はプロパティを設定するための `With*` メソッドと、コレクション(バリデータなど)に追加するための `Add*` メソッドを提供しています。

## テキストセレクタ

`Select` と `MultiSelect` では、項目の表示方法を制御するカスタム関数を提供できます:

```csharp
var user = Prompt.Select("Select user", users, textSelector: u => u.Name);
```

## ページネーション

`Select` と `MultiSelect` は `pageSize` パラメータによるページネーションをサポートしています:

```csharp
var city = Prompt.Select("Select your city",
new[] { "Seattle", "London", "Tokyo", "New York", "Singapore", "Shanghai" },
pageSize: 3);
```

## ループ選択

デフォルトでは、選択リストは先頭または末尾に到達するとループします。これはオプションクラスで無効にできます:

```csharp
var city = Prompt.Select(new SelectOptions<string>
{
Message = "Select your city",
Items = new[] { "Seattle", "London", "Tokyo" },
LoopingSelection = false
});
```
85 changes: 85 additions & 0 deletions docs/ja/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# 設定

Sharprompt では、プロンプトの外観と動作をグローバルにカスタマイズできます。

## シンボル

プロンプトで使用されるシンボルをカスタマイズできます:

```csharp
Prompt.Symbols.Prompt = new Symbol("🤔", "?");
Prompt.Symbols.Done = new Symbol("😎", "V");
Prompt.Symbols.Error = new Symbol("😱", ">>");

var name = Prompt.Input<string>("What's your name?");
```

`Symbol` クラスは 2 つの引数を取ります: Unicode 値と、Unicode をサポートしないターミナル用のフォールバック値です。

### 利用可能なシンボル

| シンボル | デフォルト (Unicode) | デフォルト (フォールバック) | 説明 |
|--------|-------------------|-------------------|-------------|
| `Prompt` | `?` | `?` | プロンプトメッセージの前に表示 |
Comment on lines +21 to +23
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「利用可能なシンボル」の表が || で始まっており、Markdown では先頭に空列が表示されます。ヘッダー/区切り行の行頭を | 1つに修正してください。

Copilot uses AI. Check for mistakes.
| `Done` | `✔` | `V` | プロンプト完了時に表示 |
| `Error` | `»` | `>>` | バリデーション失敗時に表示 |
| `Selector` | `›` | `>` | 現在ハイライトされている項目を指す |
| `Selected` | `◉` | `(*)` | MultiSelect で選択済みの項目を示す |
| `NotSelect` | `◯` | `( )` | MultiSelect で未選択の項目を示す |

## カラースキーマ

プロンプトで使用される色をカスタマイズできます:

```csharp
Prompt.ColorSchema.Answer = ConsoleColor.DarkRed;
Prompt.ColorSchema.Select = ConsoleColor.DarkCyan;

var name = Prompt.Input<string>("What's your name?");
```

### 利用可能な色

| プロパティ | デフォルト | 説明 |
|----------|---------|-------------|
| `DoneSymbol` | `Green` | 完了シンボルの色 |
| `PromptSymbol` | `Green` | プロンプトシンボルの色 |
| `Answer` | `Cyan` | ユーザーの回答の色 |
| `Select` | `Green` | 選択項目の色 |
| `Error` | `Red` | エラーメッセージの色 |
| `Hint` | `DarkGray` | ヒントとプレースホルダーの色 |
| `DisabledOption` | `DarkCyan` | 無効な選択肢の色 |

## キャンセルのサポート

デフォルトでは、`Ctrl+C` を押すとデフォルト値が返されます。この動作を変更して例外をスローさせることができます:
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

キャンセル動作の説明が現状の実装と一致していません。Ctrl+C(および Escape)はキャンセルコールバックを呼び出し、Prompt.ThrowExceptionOnCancel が true の場合は PromptCanceledException をスローし、デフォルトでは Environment.Exit(1) でプロセス終了します(「デフォルト値が返る」わけではありません)。説明を実装に合わせて修正してください。

Suggested change
デフォルトでは、`Ctrl+C` を押すとデフォルト値が返されます。この動作を変更して例外をスローさせることができます:
デフォルトでは、`Ctrl+C` `Esc` を押すとキャンセルコールバックが呼び出され、その後 `Environment.Exit(1)` によってプロセスが終了します。`Prompt.ThrowExceptionOnCancel``true` に設定すると、代わりに `PromptCanceledException` がスローされます:

Copilot uses AI. Check for mistakes.

```csharp
Prompt.ThrowExceptionOnCancel = true;

try
{
var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");
}
catch (PromptCanceledException ex)
{
Console.WriteLine("Prompt canceled");
}
```

## カルチャ

ローカライズされたメッセージのカルチャを設定します:

```csharp
Prompt.Culture = new CultureInfo("ja");
```

## コンソールドライバー

カスタムコンソールドライバーファクトリを提供できます:

```csharp
Prompt.ConsoleDriverFactory = () => new MyCustomConsoleDriver();
```
52 changes: 52 additions & 0 deletions docs/ja/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# はじめに

## インストール

NuGet から Sharprompt をインストールします:

::: code-group

```powershell [Package Manager]
Install-Package Sharprompt
```

```sh [.NET CLI]
dotnet add package Sharprompt
```

:::

## クイックスタート

```csharp
using Sharprompt;

// シンプルな入力
var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");

// パスワード入力
var secret = Prompt.Password("Type new password",
validators: new[] { Validators.Required(), Validators.MinLength(8) });
Console.WriteLine("Password OK");

// 確認
var answer = Prompt.Confirm("Are you ready?", defaultValue: true);
Console.WriteLine($"Your answer is {answer}");
```

## サンプルの実行

リポジトリには全プロンプトタイプのサンプルプロジェクトが含まれています:

```sh
dotnet run --project samples/Sharprompt.Example
```

## サポートされているプラットフォーム

| プラットフォーム | ターミナル |
|----------|----------|
| Windows | コマンドプロンプト、PowerShell、Windows Terminal |
Comment on lines +48 to +50
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

サポートされているプラットフォームの表が || で始まっているため、Markdown で先頭に空列が入ります。行頭を | 1つに修正してください。

Copilot uses AI. Check for mistakes.
| Linux | Windows Terminal (WSL 2)、各種ターミナルエミュレータ |
| macOS | Terminal.app、iTerm2 など |
32 changes: 32 additions & 0 deletions docs/ja/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
layout: home

hero:
name: Sharprompt
text: C# 向けの対話型コマンドラインプロンプト
tagline: 対話型 CLI アプリケーションを構築するためのシンプルでクロスプラットフォームなフレームワーク
image:
src: /icon.png
alt: Sharprompt
actions:
- theme: brand
text: はじめに
link: /ja/getting-started
- theme: alt
text: GitHub で見る
link: https://github.com/shibayan/Sharprompt

features:
- title: マルチプラットフォーム
details: Windows、Linux、macOS の様々なターミナルエミュレータで動作します。
- title: 豊富なプロンプトタイプ
details: Input、Password、Select、MultiSelect、List、Confirm、モデルベースの Bind プロンプトをサポートしています。
- title: バリデーション
details: 必須フィールド、最小/最大文字数、正規表現の組み込みバリデータを提供しています。
- title: Unicode サポート
details: マルチバイト文字と絵文字を完全にサポートしています 😀🎉
- title: カスタマイズ可能
details: シンボル、カラースキーマ、キャンセル動作を自由に設定できます。
- title: Fluent API
details: 可読性の高いクリーンな Fluent インターフェースでプロンプトを構築できます。
---
Loading
Loading