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

Port to clap v3 #479

Closed
wants to merge 3 commits into from
Closed

Port to clap v3 #479

wants to merge 3 commits into from

Conversation

rsdy
Copy link
Contributor

@rsdy rsdy commented Apr 6, 2021

This is a reasonably straightforward port of Abscissa to Clap v3 using the custom derives.
I removed most of the command subsystem (EntryPoint, Usage, Help) since Clap takes over most of those roles.

To demonstrate how this could work, I also migrated the CLI.

The ergonomics might be improved, as subcommands work differently in Clap than Gumdrop. This is best seen in the commands.rs file of the CLI and gen.rs root command. Embedding subcommands can get tedious quickly.

Another gotcha I found is that #[derive(Runnable)] will not work for structs in its current form, so a manual implementation is necessary.

If this changeset looks like a viable approach, I can take a look at porting the template.

Resolves #298

cli/Cargo.toml Outdated Show resolved Hide resolved
@tony-iqlusion
Copy link
Member

Thanks! This is definitely wanted and we're glad you opened the PR!

Per the clap v3 docs:

https://crates.io/crates/clap/3.0.0-beta.2

We have a 3.0.0-beta.2 prerelease out but we do not give any guarantees that it's API is stable. We do not have a changelog yet which will be written down after we are sure about the API stability. We recommend users to not update to the prerelease version yet and to wait for the official 3.0.

We definitely want to merge a PR like this after the official 3.0 release, but per that message, we don't want to do it beforehand.

@rsdy
Copy link
Contributor Author

rsdy commented Apr 6, 2021

@tony-iqlusion Happy to keep ironing out ergonomics issues and templates until Clap stabilises.

@rsdy rsdy marked this pull request as ready for review April 7, 2021 07:11
@rsdy
Copy link
Contributor Author

rsdy commented Apr 7, 2021

I've ported forward all the templates, and tests pass. I am extremely grateful for the test suite!

I've tried re-introducing an EntryPoint so that the application template doesn't need to deal with config and verbose, but nether trait objects or generics will work due to the Clap derive macro. Overall, having that code generated might slightly increase flexibility, but at the cost of more noise.

rsdy added 3 commits May 25, 2021 00:24
This removes versioning support from Abscissa, and trusts clap
completely to deal with that. This also means what the `version`
subcommand is gone in favour of `--version`.
@tony-iqlusion
Copy link
Member

Closing in favor of #562, which builds upon this work.

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.

Replace gumdrop with clap v3?
2 participants