From 4588e17f7ddacd8391a5c881a209735e08d48797 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 4 Aug 2026 13:26:48 +0800 Subject: feat: add entry metadata system with compile-time typed values Add `Metadata` trait and `#[metadata(Entry)]` attribute macro to attach arbitrary, compile-time-typed metadata to entries. Implement `ProgramCollect::get_metadata()` for runtime retrieval, backed by a global registry populated by `register_metadata!`. Extend `pathf` with `MetadataPattern` to resolve metadata types across modules at build time. Add two examples demonstrating metadata usage with and without pathf integration. --- examples/test-examples.toml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'examples/test-examples.toml') diff --git a/examples/test-examples.toml b/examples/test-examples.toml index b74c9a5..03df5e1 100644 --- a/examples/test-examples.toml +++ b/examples/test-examples.toml @@ -327,3 +327,38 @@ expect.result = "Hello, Alice" command = "goodbye" expect.exit-code = 0 expect.result = "Goodbye!" + +[[test.example-metadata]] +command = "greet" +expect.exit-code = 0 +expect.result = "Hello, World!" + +[[test.example-metadata]] +command = "greet Alice" +expect.exit-code = 0 +expect.result = "Hello, Alice!" + +[[test.example-metadata]] +command = "desc" +expect.exit-code = 0 +expect.result = "EntryGreet desc = ok" + +[[test.example-metadata]] +command = "nodoc" +expect.exit-code = 0 +expect.result = "EntryDescription has no description" + +[[test.example-combine-pathf-metadata]] +command = "hello" +expect.exit-code = 0 +expect.result = "Hello, World!" + +[[test.example-combine-pathf-metadata]] +command = "hello Alice" +expect.exit-code = 0 +expect.result = "Hello, Alice!" + +[[test.example-combine-pathf-metadata]] +command = "desc" +expect.exit-code = 0 +expect.result = "EntryHello desc = okay" -- cgit