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

Now that we have version and authors macros we should add App::new_with_defaults that uses both #600

Closed
rtaycher opened this issue Jul 24, 2016 · 2 comments
Milestone

Comments

@rtaycher
Copy link
Contributor

I think it's generally best to make cmdline parsing as simple and short as possible.

In that spirit I'd like to propose adding a way to initialize version/authors
implicitly since this would add make it more difficult to build an app without cargo
(although you could just define the 2 env variable manually) and since
App::new doesn't depend on it currently I thought people might be opposed to
changing it.

Instead how about adding a new method App::new_with_defaults?

@rtaycher
Copy link
Contributor Author

Implementation

pub fn new_with_defaults<S: Into<String>>(n: S) -> Self {
    App { p: Parser::with_name(n.into()) }.version(crate_version!()).author(crate_authors!())
}

@kbknapp
Copy link
Member

kbknapp commented Jul 24, 2016

I think is a fine idea. I'd like to hear a few more opinions on the matter before adding it, primarily around the naming. I think new_with_defaults is kind of long. Maybe just App::with_defaults(name)?

@kbknapp kbknapp added this to the 2.10.5 milestone Aug 26, 2016
kbknapp added a commit that referenced this issue Aug 28, 2016
… crate_version! macros

One can now use

```rust
let a = App::with_defaults("My Program");

// same as
let a2 = App::new("My Program")
	.version(crate_version!())
	.author(crate_authors!());
```

Closes #600
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

No branches or pull requests

2 participants