Skip to content

Commit

Permalink
Add a replacement cli-parsing function for Opt that can be used in …
Browse files Browse the repository at this point in the history
…quickstart with no external dependencies
  • Loading branch information
johnhurt authored and drcaramelsyrup committed Jun 28, 2024
1 parent 86e6cd2 commit c67b5d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dad4171e22fa0f38c7dc19247c36f4004d1245de
8f4c536768b4ed3720cc4a6e651d0ed519aa6a60
2 changes: 1 addition & 1 deletion docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
...
}
```
Expand Down
9 changes: 9 additions & 0 deletions pingora-core/src/server/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit c67b5d0

Please sign in to comment.