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

Make structopt-derive's dependency on structopt optional #45

Closed
killercup opened this issue Jan 21, 2018 · 3 comments · Fixed by #50
Closed

Make structopt-derive's dependency on structopt optional #45

killercup opened this issue Jan 21, 2018 · 3 comments · Fixed by #50
Labels
enhancement We would love to have this feature! Feel free to supply a PR

Comments

@killercup
Copy link
Contributor

So, I have a very weird request. I'm trying to re-export stuctopt-derive in a crate, but since this code

const #dummy_const: () = {
extern crate structopt as _structopt;
use structopt::StructOpt;

expands to extern crate structopt, my consumers would have to add structopt to their dependencies, which I want to avoid. Is there another option of doing this? E.g., making this part of the derive optional (with a feature flag).

cc killercup/quicli#9

@TeXitoi
Copy link
Owner

TeXitoi commented Jan 22, 2018

This trick was taken to serde. Thus how do you manage serde case ?

Then, if you have the trick to only depend on structopt without depending on structopt-derive I'm interested by the trick that may simplify this particular use case.

@TeXitoi
Copy link
Owner

TeXitoi commented Jan 22, 2018

The feature of this trick is to compile without the user needing to extern crate structopt

@killercup
Copy link
Contributor Author

Thus how do you manage serde case ?

By opening the same issue there as well, of course ;) serde-rs/serde#1147

Since there are already some ideas in this thread, maybe we can discuss options there? Otherwise I'll let you know if you find a solution :)

The feature of this trick is to compile without the user needing to extern crate structopt

And it's a great trick :) The thing is that my crate already re-exports structopt::StructOpt;, and users of quicli should always glob import the prelude that contains StructOpt. In such a case, the user doesn't need extern crate structopt;.

@TeXitoi TeXitoi added enhancement We would love to have this feature! Feel free to supply a PR question labels Jan 29, 2018
TeXitoi added a commit that referenced this issue Jan 29, 2018
As using structopt without structopt_derive is quite meaningless, reexport
structopt_derive, symplifying the usage.

Inspired by the failure crate.

fix #45
@TeXitoi TeXitoi removed the question label Jan 29, 2018
TeXitoi added a commit that referenced this issue Feb 3, 2018
As using structopt without structopt_derive is quite meaningless, reexport
structopt_derive, symplifying the usage.

Inspired by the failure crate.

fix #45
TeXitoi added a commit that referenced this issue Feb 3, 2018
As using structopt without structopt_derive is quite meaningless, reexport
structopt_derive, symplifying the usage.

Inspired by the failure crate.

fix #45
Eijebong pushed a commit to Eijebong/structopt that referenced this issue Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement We would love to have this feature! Feel free to supply a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants