aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKevin Guthrie <[email protected]>2024-06-25 11:13:36 -0400
committerEdward Wang <[email protected]>2024-06-28 12:34:25 -0700
commitc67b5d0141af939827777c66e95fbb530ca14d33 (patch)
tree219f93af203e1fbc659f9dcd72d6a9b425a1e9ac
parent86e6cd29121b8ae62e343ad73cd5cc7717b91126 (diff)
downloadpingora-c67b5d0141af939827777c66e95fbb530ca14d33.tar.gz
pingora-c67b5d0141af939827777c66e95fbb530ca14d33.zip
Add a replacement cli-parsing function for `Opt` that can be used in quickstart with no external dependencies
-rw-r--r--.bleep2
-rw-r--r--docs/quick_start.md2
-rw-r--r--pingora-core/src/server/configuration/mod.rs9
3 files changed, 11 insertions, 2 deletions
diff --git a/.bleep b/.bleep
index e85542a..dcda9dd 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-dad4171e22fa0f38c7dc19247c36f4004d1245de \ No newline at end of file
+8f4c536768b4ed3720cc4a6e651d0ed519aa6a60 \ No newline at end of file
diff --git a/docs/quick_start.md b/docs/quick_start.md
index 5099f7e..8a3b796 100644
--- a/docs/quick_start.md
+++ b/docs/quick_start.md
@@ -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();
...
}
```
diff --git a/pingora-core/src/server/configuration/mod.rs b/pingora-core/src/server/configuration/mod.rs
index 0bd3222..5174d40 100644
--- a/pingora-core/src/server/configuration/mod.rs
+++ b/pingora-core/src/server/configuration/mod.rs
@@ -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::*;