From a97f8d32a856ae72d128ed61aebfb20709b7d4b9 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 4 Aug 2026 15:00:42 +0800 Subject: docs: document completion description support Update changelog and issue tracker notes for the enhanced `default_completion` behavior. --- docs/dev/pages/issues/the-shit-time.md | 40 +++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'docs/dev') 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!(); +``` -- cgit