From aa55ca91b24aa3c09cb37b1490717fd52c52228e Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Sat, 10 Feb 2024 15:14:04 -0800 Subject: [PATCH 1/2] Add docs for the new `impl_*` macros. --- src/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 429ce5e..6221ee7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,6 +193,16 @@ pub fn parse() -> Result { } mod macros { + /// Creates a generic `HELP` string for [`OnlyArgs`] implementations. + /// + /// The string will take the following form, filling in details from the package's `Cargo.toml`: + /// + /// ```text + /// {package-name} v{package-version} + /// {package-description} + /// ``` + /// + /// [`OnlyArgs`]: crate::OnlyArgs #[macro_export] macro_rules! impl_help { () => { @@ -207,6 +217,15 @@ mod macros { }; } + /// Creates a generic `VERSION` string for [`OnlyArgs`] implementations. + /// + /// The string will take the following form, filling in details from the package's `Cargo.toml`: + /// + /// ```text + /// {package-name} v{package-version} + /// ``` + /// + /// [`OnlyArgs`]: crate::OnlyArgs #[macro_export] macro_rules! impl_version { () => { From 55ed2f4a55a9e698346a5bb9eac1f748ba20b29a Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Sat, 10 Feb 2024 15:18:14 -0800 Subject: [PATCH 2/2] Add impl macros to example docs. --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 6221ee7..5b1e612 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,6 +155,9 @@ impl std::error::Error for CliError { /// } /// /// impl OnlyArgs for Args { +/// const HELP: &'static str = onlyargs::impl_help!(); +/// const VERSION: &'static str = onlyargs::impl_version!(); +/// /// fn parse(args: Vec) -> Result { /// let mut verbose = false; ///