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

A better way to handle empty strings in argument values #122

Closed
Byron opened this issue May 17, 2015 · 4 comments
Closed

A better way to handle empty strings in argument values #122

Byron opened this issue May 17, 2015 · 4 comments
Assignees
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@Byron
Copy link
Contributor

Byron commented May 17, 2015

Currently it is possible to pass an empty string to arguments defined like this (maybe it's a valid value to all of them):

Arg::new("from-stop")
             .required(true)

On the command-line, it's now possible to pass in an empty string like so:

$ trains shortest-route A ""

I believe it's too far fetched to disallow empty strings in general, but it would be great if I could set a flag (maybe even it's default on) on the Arg type to let the parser handle empty values for me.

This could look like this:

Arg::new("to-stop")
       .allow_empty_values(false)
       .required(true)

If such a feature does not exist on parser level, each client will have to implement its own check.

@kbknapp
Copy link
Member

kbknapp commented May 17, 2015

I think this is a valid suggestion. Let me play with an implementation and I'll post back with the solution.

@kbknapp kbknapp self-assigned this May 17, 2015
@kbknapp kbknapp added the C-enhancement Category: Raise on the bar on expectations label May 17, 2015
@kbknapp
Copy link
Member

kbknapp commented May 17, 2015

I have the initial work on this done, but I'm going to roll it into a larger update tonight since I don't have time to finish it until later today. I'll posy back later today once its complete ;)

@Byron
Copy link
Contributor Author

Byron commented May 17, 2015

Thanks! No reason to hurry though, as I am just playing it safe and used
'stdin' instead of '-' for the final toy project.
And Google.rs will use this capability once available.
On Sun 17 May 2015 at 19:04 Kevin K. notifications@github.com wrote:

I have the initial work on this done, but I'm going to roll it into a
larger update tonight since I don't have time to finish it until later
today. I'll posy back later today once its complete ;)


Reply to this email directly or view it on GitHub
#122 (comment).

@kbknapp
Copy link
Member

kbknapp commented May 17, 2015

Should be good now :) Use v0.9.1 on crates.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants