Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clap to v4 #15

Merged
merged 4 commits into from
Mar 18, 2023
Merged

Update clap to v4 #15

merged 4 commits into from
Mar 18, 2023

Conversation

CosmicHorrorDev
Copy link
Collaborator

Resolves #13

This updates clap to v4 and switches to the derive API. It looks like the flag order got changed to the declaration order, so it's possible you may want that changed to match, but other than that everything seems more or less the same

I can't seem to get the author or version to set in the help message no matter what I try (enabling the cargo command, explicitly setting it, using clap::crate_authors!(), etc), so I'll have to dig into that some more

The help text before and after

image

@Aloso
Copy link
Owner

Aloso commented Mar 18, 2023

Thank you for this. To include version and author, it seems like help_template must be used:

#[command(
    author,
    version,
    about,
    max_term_width = 100,
    help_template = "\
{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}

{all-args}{after-help}"
)]

I found this by looking at the docs for clap 4.1.8, since the documentation for Command is missing in the latest version.

@CosmicHorrorDev
Copy link
Collaborator Author

Nice find! I wonder if that was an intentional change by clap or not?

Either way that should work fine. You can push a commit for it if ya want since I'll be AFK for the rest of the day

@CosmicHorrorDev
Copy link
Collaborator Author

I missed this note under Command::authors() before. It does indeed seem to be an intentional change

NOTE: A custom help_template is needed for author to show up.

@Aloso
Copy link
Owner

Aloso commented Mar 18, 2023

@CosmicHorrorDev I just pushed a change, which adds the version and author and minor tweaks to the help message.

@CosmicHorrorDev
Copy link
Collaborator Author

Thanks! It all LGTM 👍

@Aloso
Copy link
Owner

Aloso commented Mar 18, 2023

It does indeed seem to be an intentional change

Yes, though I can't say I approve. When someone writes #[command(version, author)], that usually means that they want this information to be displayed.

@CosmicHorrorDev
Copy link
Collaborator Author

I'm in the same boat. It seems incredibly uncommon that someone wants to set the author info for something other than the help message

I know that clap v0.5 is planned, so could be worth opening a discussion to voice your opinion, and potentially get better insight into things

@Aloso
Copy link
Owner

Aloso commented Mar 18, 2023

Yes, I might do that.

The code looks good, thank you for the contribution 🙂

@Aloso Aloso merged commit 0b08bf5 into Aloso:main Mar 18, 2023
@CosmicHorrorDev
Copy link
Collaborator Author

I've got more contributions planned too 😁

I'll make sure to open issues beforehand though. No worries

@Aloso
Copy link
Owner

Aloso commented Mar 18, 2023

I appreciate that! I just hope it doesn't keep you from writing blog posts 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potentially switch to clap derive API
2 participants