Closed tylerjw closed 2 weeks ago
I expect if you set package.authors
, you would get the same result.
In clap v4, we dropped author from the default help template
You can add it back with a custom help template.
Oh, thank you for the reply. I was migrating an old project from 2 to 4 and found this.
I don't know if this is a bug or not but when I try to use the same feature via derive it doesn't seem to work (output is missing author):
const HELP_TEMPLATE: &str = "\
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}
{all-args}{after-help}";
#[derive(Parser, Debug)]
#[command(version, about, help_template = HELP_TEMPLATE)]
author
attribute is missing.
The following works for me
#!/usr/bin/env nargo
---
[package]
description = "some description"
authors = ["me"]
[dependencies]
clap = { version = "4", features = ["derive"] }
---
use clap::Parser;
const HELP_TEMPLATE: &str = "\
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}
{all-args}{after-help}";
#[derive(Parser, Debug)]
#[command(author, version, about, help_template = HELP_TEMPLATE)]
struct Cli {
}
fn main() {
Cli::parse();
}
Thank you again; I didn't understand that I needed the author attribute.
Yeah, structopt required no_author
and such to opt-out. We switched to explicit opt-in.
btw for 3.0.0 and 4.0.0 we had migration guides (e.g. 3.0.0 and specifically called out subtle breaking changes like this, e.g.
From structopt 0.3.25
- By default, the App isn't initialized with crate information anymore. Now opt-in via #[clap(author)], #[clap(about)], #[clap(version)] (https://github.com/clap-rs/clap/issues/3034)
Please complete the following tasks
Rust Version
rustc 1.78.0 (9b00956e5 2024-04-29)
Clap Version
4.5.7
Minimal reproducible code
workspace Cargo.toml
test/Cargo.toml
Steps to reproduce the bug with the above code
Actual Behaviour
Expected Behaviour
Additional Context
No response
Debug Output