Open lnicola opened 6 years ago
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?
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
.
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.
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.