mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-19 18:21:34 +02:00
Add a replacement cli-parsing function for Opt
that can be used in quickstart with no external dependencies
This commit is contained in:
parent
86e6cd2912
commit
c67b5d0141
3 changed files with 11 additions and 2 deletions
2
.bleep
2
.bleep
|
@ -1 +1 @@
|
|||
dad4171e22fa0f38c7dc19247c36f4004d1245de
|
||||
8f4c536768b4ed3720cc4a6e651d0ed519aa6a60
|
|
@ -237,7 +237,7 @@ take advantage of with single-line change.
|
|||
|
||||
```rust
|
||||
fn main() {
|
||||
let mut my_server = Server::new(Some(Opt::default())).unwrap();
|
||||
let mut my_server = Server::new(Some(Opt::parse_args())).unwrap();
|
||||
...
|
||||
}
|
||||
```
|
||||
|
|
|
@ -227,6 +227,15 @@ impl ServerConf {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create an instance of Opt by parsing the current command-line args.
|
||||
/// This is equivalent to running `Opt::parse` but does not require the
|
||||
/// caller to have included the `clap::Parser`
|
||||
impl Opt {
|
||||
pub fn parse_args() -> Self {
|
||||
Opt::parse()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue