-
Notifications
You must be signed in to change notification settings - Fork 2
Conversation
This commit simply imports the structopt codebase and history and does some simple renames. The codebase doesn't compile yet as this is purely a WIP and starting point.
f5b2202
to
2bc32e0
Compare
07871c1
to
ab62b17
Compare
…development version
097f9bd
to
98752e5
Compare
… moved derive traits into mainline clap
98752e5
to
023ee47
Compare
…function to arg_enum mod where its used
…rive into import-structopt
This commit starts to move the StructOpt trait into three smaller traits (Parse, IntoApp, and FromArgMatches) as well as a convenience triat which combines all three (Clap). It also continues work on renaming structopt->clap Finally, it starts to move all the impls into their own mods.
This is almost building. The primary issue is I can't seem to get the custom attributes to be recognized ( Also, I've noticed a design flaw in splitting the traits; the use clap::Parse;
let mystruct: MyStruct = <MyStruct as Parse>::parse(); which is silly. Instead I believe we should move the I've also removed the dep of |
I can't see the trait definitions to understand your That's a bit sad to loose all the structopt history and contributors. It would be great to be able to merge structopt in clap_derive during the transition. Spliting the trait can be done in StructOpt for testing, and moving the files of structopt for easy merging between StructOpt and clap_derive could be great. I also thing that there is 2 breaking changes that can be interesting:
|
They're defined in the clap repo, but look at the
You're totally correct. Now that I'm getting more familiar with codebase I'm willing to scrap this PR and instead do a proper import. It's not my intention at all to remove the history or credit of those who have contributed! I'd also be willing to delete this repo, and do all the work in the structopt proper repo. However, I'm not sure how you'd feel about renaming that repo and eventually transferring to the github.com/clap-rs org (which is where clap and all related crates will be moved). The hardest part with working in the structopt proper repo is this code is setup like this:
|
I commented on the first breaking change, but I'm less in favor of the second. I'm personally fine with the "forced" workaround listed, and not a huge fan of too much "black magic" like you mentioned 👍 |
So we agree on the features :-) |
I've re-done the master branch of this repo to properly import structopt with all of it's history and commits. Some commits aren't pulled in (such as those on structopt/src/lib.rs) because it doesn't directly translate to something in this repo, as that logic is contained in the main clap repo. Now I can start the work from this PR on the new master branch which will now keep track of the proper history. |
I think the Parse trait is useless, just add the Parse method in FromArgMatches trait. |
|
And the |
This is a work in progress, do not merge
Started doing the port of
structopt
and set up a bunch of initial scaffolding for this crate. Here's the key notes, which I'll add to as I make commits:This branch is based on structopt@d983649822b
clap
contains all the public derive traits and such (currently behind theunstable
feature)clap_derive
(this crate) which contains the procedural macros and custom derive bitsderive
able traits are:IntoApp
which provides:into_app() -> clap::App
impl From<MyStruct> for clap::App
FromArgMatches
which providesfrom_argmatches(clap::ArgMatches) -> Self
try_from_argmatches(clap::ArgMatches) -> Result<Self, clap::Error>
impl From<clap::ArgMatches> for MyApp
impl TryFrom<clap::ArgMatches> for MyApp
Parse
which providesparse() -> Self
(i.e.clap::App::get_matches
)try_parse() -> Result<Self, clap::Error>
(i.e.clap::App::get_matches_safe
)parse_from() -> Self where I: IntoIterator<Item = T>, T: Into<OsString>
(i.e.clap::App::get_matches_from
)try_parse_from(I) -> Result<Self, clap::Error> where I: IntoIterator<Item = T>, T: Into<OsString>
(i.e.clap::App::get_matches_from_safe
)Clap
which is just a convenience and provides all three of the above traitsArgEnum
which providesvariants() -> [&'static str; N]
impl FromStr for MyEnum
clap_derive/tests
clap_derive/examples
clap_derive
(no longer plural and uses snake case)Closes #8
Closes #5