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

Setting a default port? #15

Open
lnicola opened this issue Jul 24, 2018 · 3 comments
Open

Setting a default port? #15

lnicola opened this issue Jul 24, 2018 · 3 comments

Comments

@lnicola
Copy link

lnicola commented Jul 24, 2018

bind_or can be used, but the default won't show up in the help message. I don't think there's anything that can be done to make it visible, but it's worth considering it.

There's also the issue of it failing due to e.g. permission errors. If I specify a port in the command line, I don't expect the default to be used if another program is listening on it.

@yoshuawuyts
Copy link
Collaborator

bind_or can be used, but the default won't show up in the help message. I don't think there's anything that can be done to make it visible, but it's worth considering it.

Completely agree.

There's also the issue of it failing due to e.g. permission errors. If I specify a port in the command line, I don't expect the default to be used if another program is listening on it.

That's an excellent point; not sure what the best approach is to dealing with that. For me the .bind_or() method is most useful for development; so cargo run just works. But maybe it's too leaky of an abstraction, and we'd be better off removing it entirely?

@lnicola
Copy link
Author

lnicola commented Jul 25, 2018

Maybe the user could define their own Port struct and then use a derive from this crate that either expands to a #[structopt] or (better) to the stuff that structopt does to interact with clap.

@lnicola
Copy link
Author

lnicola commented Jul 25, 2018

Another thing, right now you can't change the help message and environment variable name (I think). I love the idea of being able to bind to a port regardless of how it's configured, but this approach seems a bit finicky to me.

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