aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/_zh_CN/pages/10-help.md6
-rw-r--r--docs/_zh_CN/pages/4-render-result.md4
-rw-r--r--docs/_zh_CN/pages/concepts/1-the-pipeline.md4
-rw-r--r--docs/_zh_CN/pages/concepts/4-program-collect.md2
-rw-r--r--docs/dev/pages/issues/the-shit-time.md13
-rw-r--r--docs/pages/10-help.md6
-rw-r--r--docs/pages/4-render-result.md4
-rw-r--r--docs/pages/concepts/1-the-pipeline.md4
-rw-r--r--docs/pages/concepts/4-program-collect.md2
9 files changed, 28 insertions, 17 deletions
diff --git a/docs/_zh_CN/pages/10-help.md b/docs/_zh_CN/pages/10-help.md
index 1c4e410..a399ae3 100644
--- a/docs/_zh_CN/pages/10-help.md
+++ b/docs/_zh_CN/pages/10-help.md
@@ -27,14 +27,14 @@ fn help_greet(_entry: EntryGreet) {
## 全局帮助
-你也可以为 `ErrorDispatcherNotFound` 写帮助,作为"根帮助":
+你也可以为 `EntryFallback` 写帮助,作为"根帮助":
```rust
@@@use mingling::macros::help;
@@@use mingling::macros::buffer;
// 用户直接输入 --help 时触发
#[help(buffer)]
-fn help_root(entry: ErrorDispatcherNotFound) {
+fn help_root(entry: EntryFallback) {
r_println!("Usage: my-cli <command>");
r_println!("Commands:");
r_println!(" greet Say hello");
@@ -42,7 +42,7 @@ fn help_root(entry: ErrorDispatcherNotFound) {
```
> [!TIP]
-> `ErrorDispatcherNotFound` 是 `gen_program!()` 自动生成的类型,代表"没有匹配到任何命令"的情况。为它写 `#[help]` 就是给程序的根命令加帮助。
+> `EntryFallback` 是 `gen_program!()` 自动生成的类型,代表"没有匹配到任何命令"的情况。为它写 `#[help]` 就是给程序的根命令加帮助。
## 需要 Setup 配合
diff --git a/docs/_zh_CN/pages/4-render-result.md b/docs/_zh_CN/pages/4-render-result.md
index 8b29fca..7f66c71 100644
--- a/docs/_zh_CN/pages/4-render-result.md
+++ b/docs/_zh_CN/pages/4-render-result.md
@@ -116,13 +116,13 @@ cargo run -- great
## 补上 Fallback
-`gen_program!()` 自动生成了一个 `ErrorDispatcherNotFound` 类型,包裹 `Vec<String>`——它存的是用户输入的那些没匹配到的命令。你只需要给它写一个 Renderer:
+`gen_program!()` 自动生成了一个 `EntryFallback` 类型,包裹 `Vec<String>`——它存的是用户输入的那些没匹配到的命令。你只需要给它写一个 Renderer:
```rust
use mingling::macros::buffer;
#[renderer(buffer)]
-fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) {
+fn render_entry_fallback(err: EntryFallback) {
if err.inner.is_empty() {
r_println!("Unknown command");
} else {
diff --git a/docs/_zh_CN/pages/concepts/1-the-pipeline.md b/docs/_zh_CN/pages/concepts/1-the-pipeline.md
index b0bb19d..9c74087 100644
--- a/docs/_zh_CN/pages/concepts/1-the-pipeline.md
+++ b/docs/_zh_CN/pages/concepts/1-the-pipeline.md
@@ -42,12 +42,12 @@ graph TD
graph LR
Input["用户输入"] --> M{匹配 Dispatcher}
M -->|"匹配到"| E["调用 dispatcher.begin(args)<br/>返回包装好的 Entry"]
- M -->|"未匹配"| NF["build_dispatcher_not_found<br/>生成 ErrorDispatcherNotFound"]
+ M -->|"未匹配"| NF["build_entry_fallback<br/>生成 EntryFallback"]
```
匹配成功后调用 `dispatcher.begin(args)`,返回 `ChainProcess::Ok((AnyOutput, _))`,即包装好用户输入参数的 Entry 类型。
-如果没有匹配到任何 Dispatcher,则生成 `ErrorDispatcherNotFound`(包裹完整的输入参数),后续可以被 Renderer 处理显示 "Command not found"。
+如果没有匹配到任何 Dispatcher,则生成 `EntryFallback`(包裹完整的输入参数),后续可以被 Renderer 处理显示 "Command not found"。
### 2. Help 短路
diff --git a/docs/_zh_CN/pages/concepts/4-program-collect.md b/docs/_zh_CN/pages/concepts/4-program-collect.md
index f5e6b8f..a0236f6 100644
--- a/docs/_zh_CN/pages/concepts/4-program-collect.md
+++ b/docs/_zh_CN/pages/concepts/4-program-collect.md
@@ -21,7 +21,7 @@
- **`render`** —— 根据 `member_id` 调用对应的 `#[renderer]` 函数,写入 `RenderResult`
- **`render_help`** —— 根据 `member_id` 调用对应的 `#[help]` 函数
- **`has_chain` / `has_renderer`** —— 判断某个变体有没有对应的处理函数
-- **`build_dispatcher_not_found` / `build_renderer_not_found` / `build_empty_result`** —— 三个内置降级类型,处理边界情况
+- **`build_entry_fallback` / `build_renderer_not_found` / `build_empty_result`** —— 三个内置降级类型,处理边界情况
这套映射在运行时通过枚举匹配来完成——编译期只生成了枚举和匹配分支,实际的函数调用发生在运行时。
diff --git a/docs/dev/pages/issues/the-shit-time.md b/docs/dev/pages/issues/the-shit-time.md
index 9d6c429..ece670e 100644
--- a/docs/dev/pages/issues/the-shit-time.md
+++ b/docs/dev/pages/issues/the-shit-time.md
@@ -9,7 +9,7 @@ Of course, you can also contribute to this document.
---
-## Why is there no fallback completion logic?
+## Why is there no fallback completion logic? (Solved)
(completion) (fallback)
@@ -35,6 +35,17 @@ fn complete(ctx: &ShellContext) -> Suggest {
}
```
+Final implementation:
+
+By adding support for `EntryFallback` (formerly `ErrorDispatcherNotFound`) to the Completion system, `EntryFallback` can now be used as a completion entry point when no subcommand is matched:
+
+```rust
+#[completion(EntryFallback)]
+fn complete_fallback(_ctx: &ShellContext) -> Suggest {
+ suggest! { "fallback" }
+}
+```
+
---
## Why can't I register descriptions for commands?
diff --git a/docs/pages/10-help.md b/docs/pages/10-help.md
index 1e3ea78..d9cc557 100644
--- a/docs/pages/10-help.md
+++ b/docs/pages/10-help.md
@@ -27,14 +27,14 @@ fn help_greet(_entry: EntryGreet) {
## Global Help
-You can also write help for `ErrorDispatcherNotFound` as the "root help":
+You can also write help for `EntryFallback` as the "root help":
```rust
@@@use mingling::macros::help;
@@@use mingling::macros::buffer;
// Triggered when user passes --help directly
#[help(buffer)]
-fn help_root(entry: ErrorDispatcherNotFound) {
+fn help_root(entry: EntryFallback) {
r_println!("Usage: my-cli <command>");
r_println!("Commands:");
r_println!(" greet Say hello");
@@ -42,7 +42,7 @@ fn help_root(entry: ErrorDispatcherNotFound) {
```
> [!TIP]
-> `ErrorDispatcherNotFound` is a type generated by `gen_program!()`, representing "no matching command found." Writing `#[help]` for it adds help to the program's root command.
+> `EntryFallback` is a type generated by `gen_program!()`, representing "no matching command found." Writing `#[help]` for it adds help to the program's root command.
## Requires Setup
diff --git a/docs/pages/4-render-result.md b/docs/pages/4-render-result.md
index 9e72d09..7b63b45 100644
--- a/docs/pages/4-render-result.md
+++ b/docs/pages/4-render-result.md
@@ -116,13 +116,13 @@ cargo run -- great
## Adding a Fallback
-`gen_program!()` auto-generates an `ErrorDispatcherNotFound` type wrapping `Vec<String>`—it holds the user input that didn't match any command. You just need to write a Renderer for it:
+`gen_program!()` auto-generates an `EntryFallback` type wrapping `Vec<String>`—it holds the user input that didn't match any command. You just need to write a Renderer for it:
```rust
use mingling::macros::buffer;
#[renderer(buffer)]
-fn render_dispatcher_not_found(err: ErrorDispatcherNotFound) {
+fn render_entry_fallback(err: EntryFallback) {
if err.inner.is_empty() {
r_println!("Unknown command");
} else {
diff --git a/docs/pages/concepts/1-the-pipeline.md b/docs/pages/concepts/1-the-pipeline.md
index e73379d..2ee26d0 100644
--- a/docs/pages/concepts/1-the-pipeline.md
+++ b/docs/pages/concepts/1-the-pipeline.md
@@ -42,12 +42,12 @@ The matching rule is **prefix matching** on space-separated tokens — the longe
graph LR
Input["user input"] --> M{"match Dispatcher"}
M -->|"matched"| E["call dispatcher.begin(args)<br/>return wrapped Entry"]
- M -->|"no match"| NF["build_dispatcher_not_found<br/>generate ErrorDispatcherNotFound"]
+ M -->|"no match"| NF["build_entry_fallback<br/>generate EntryFallback"]
```
On a match, `dispatcher.begin(args)` is called, returning `ChainProcess::Ok((AnyOutput, _))` — the Entry type wrapping the user's input params.
-If no Dispatcher matches, `ErrorDispatcherNotFound` is generated (wrapping the full input), which a Renderer can later handle to display "Command not found".
+If no Dispatcher matches, `EntryFallback` is generated (wrapping the full input), which a Renderer can later handle to display "Command not found".
### 2. Help Shortcut
diff --git a/docs/pages/concepts/4-program-collect.md b/docs/pages/concepts/4-program-collect.md
index a24f115..c5203c3 100644
--- a/docs/pages/concepts/4-program-collect.md
+++ b/docs/pages/concepts/4-program-collect.md
@@ -21,7 +21,7 @@ This enum is the type of `G` in `AnyOutput<G>` — the scheduler uses enum varia
- **`render`** — calls the corresponding `#[renderer]` function by `member_id`, writes to `RenderResult`
- **`render_help`** — calls the corresponding `#[help]` function by `member_id`
- **`has_chain` / `has_renderer`** — checks whether a variant has a corresponding handler
-- **`build_dispatcher_not_found` / `build_renderer_not_found` / `build_empty_result`** — three built-in fallback types for edge cases
+- **`build_entry_fallback` / `build_renderer_not_found` / `build_empty_result`** — three built-in fallback types for edge cases
This mapping is resolved at runtime via enum matching — only the enum and match branches are generated at compile time; actual function calls happen at runtime.