Skip to content

Commit

Permalink
Normalize help messages in examples
Browse files Browse the repository at this point in the history
This makes `onlyargs_derive` output only a single blank line at the end
of the help message instead of two (which was characteristic of the
previous release). Now the output is closer between the manual trait
implementation and the derived trait impl.

Also changes the unordered list in the footer to use asterisks, which
looks a bit better in ASCII and disambiguates between flags and options.
  • Loading branch information
parasyte committed Feb 12, 2024
1 parent 51298f5 commit 466738d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/full-derive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use std::{fmt::Write as _, path::PathBuf, process::ExitCode};
/// Sums a list of numbers and writes the result to a file or standard output.
#[derive(Clone, Debug, Eq, PartialEq, OnlyArgs)]
#[footer = "Please consider becoming a sponsor 💖:"]
#[footer = " - https://github.com/sponsors/parasyte"]
#[footer = " - https://ko-fi.com/blipjoy"]
#[footer = " - https://patreon.com/blipjoy"]
#[footer = " * https://github.com/sponsors/parasyte"]
#[footer = " * https://ko-fi.com/blipjoy"]
#[footer = " * https://patreon.com/blipjoy"]
struct Args {
/// Your username.
username: String,
Expand Down
4 changes: 4 additions & 0 deletions examples/full/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ impl OnlyArgs for Args {
" -w --width NUMBER Set the width. [default: 42]\n",
"\nNumbers:\n",
" A list of numbers to sum.\n",
"\nPlease consider becoming a sponsor 💖:\n",
" * https://github.com/sponsors/parasyte\n",
" * https://ko-fi.com/blipjoy\n",
" * https://patreon.com/blipjoy\n",
);

const VERSION: &'static str = onlyargs::impl_version!();
Expand Down
3 changes: 1 addition & 2 deletions onlyargs_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ pub fn derive_parser(input: TokenStream) -> TokenStream {
format!("\n{}\n", ast.doc.join("\n"))
};
let footer = if ast.footer.is_empty() {
String::new()
"\n".to_string()
} else {
format!("\n\n{}\n", ast.footer.join("\n"))
};
Expand Down Expand Up @@ -370,7 +370,6 @@ pub fn derive_parser(input: TokenStream) -> TokenStream {
{options_help:?},
{positional_help:?},
{footer:?},
"\n",
);
const VERSION: &'static str = concat!(
Expand Down

0 comments on commit 466738d

Please sign in to comment.