-
Notifications
You must be signed in to change notification settings - Fork 151
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
structopt as main args through rust-cli/paw #187
Comments
Can't you just |
@TeXitoi unfortunately we can't because we're not allowed to implement traits for foreign types (believe it's because of orphan rules): Maybe I'm missing something tho? |
As paw-raw is very small, I'm OK adding the generic impl in the structopt crate (and not in the generated code as proposed above). |
@yoshuawuyts I let you open the PR? I don't know when I'll find the time to do that, but if you do it, it'll be faster. |
I've just created PR #192 to address this. After trying a few different methods I had to go back to doing this in the structopt macro as the error @yoshuawuyts was seeing shows up because of the way ParseArgs is invoked. The only way I could get this working was to do it in paw which introduced a dependency on structopt for paw which given the intention to move paw to std at some point (so cannot have dependencies) is not an option. |
resolved by #192 |
A few weeks ago the CLI WG released paw, a crate to try and make CLI parsing more of a first-class citizen in Rust (post). This allows arguments to be passed into
fn main
as long as a trait is implemented. Obviously we also added structopt support.So far it's been working quite well, but we think we could make this even better if we could add the trait to structopt directly:
Proposed
Current
Implementation
The patch to
structopt
would be about 6 lines inside the structopt macro:Would you be open to a patch that allows structopt to be used directly from main?
Full TCP Example
The text was updated successfully, but these errors were encountered: