diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-04 15:00:42 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-04 15:00:42 +0800 |
| commit | a97f8d32a856ae72d128ed61aebfb20709b7d4b9 (patch) | |
| tree | bfda5c3e8aab3b4bce6ec50f258dbc9a2b8ef557 /docs/dev | |
| parent | 9a231d8c163414d462a185d955e6887b64704802 (diff) | |
Update changelog and issue tracker notes for the enhanced
`default_completion` behavior.
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/pages/issues/the-shit-time.md | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/docs/dev/pages/issues/the-shit-time.md b/docs/dev/pages/issues/the-shit-time.md index ece670e..4c25e8f 100644 --- a/docs/dev/pages/issues/the-shit-time.md +++ b/docs/dev/pages/issues/the-shit-time.md @@ -48,7 +48,7 @@ fn complete_fallback(_ctx: &ShellContext) -> Suggest { --- -## Why can't I register descriptions for commands? +## Why can't I register descriptions for commands? (Solved) (completion) (dispatcher) @@ -109,3 +109,41 @@ fn desc_add(_ctx: &ShellContext) -> Suggest { // Match the corresponding function using enum values inside ThisProgram gen_program!() ``` + +Final implementation: + +`#[metadata]` registers a `Description` for each entry, and `gen_program!()` collects them. During completion, when a subcommand suggestion is generated, its owning entry's `Description` is resolved via the node path and attached as the suggestion's description text. + +```rust +use mingling::{ + ShellContext, Suggest, + macros::{command, completion, gen_program, metadata, suggest}, + metadata::Description, + setup::picker::BasicProgramSetup, +}; + +fn main() { + let mut program = ThisProgram::new(); + program.with_setup(BasicProgramSetup); + program.with_dispatcher(CMDCompletion); + program.with_dispatcher(CMDThanks); + program.exec_and_exit(); +} + +#[command] +pub fn thanks() { + println!("thanks!"); +} + +#[completion(EntryThanks)] +pub fn complete_thanks(_ctx: &ShellContext) -> Suggest { + suggest! { "alice", "bob" } +} + +#[metadata(EntryThanks)] +pub fn desc_thanks() -> Description { + Description::new("Thanks someone") +} + +gen_program!(); +``` |
