Add a replacement cli-parsing function for Opt that can be used in quickstart with no external dependencies

This commit is contained in:
Kevin Guthrie 2024-06-25 11:13:36 -04:00 committed by Edward Wang
parent 86e6cd2912
commit c67b5d0141
3 changed files with 11 additions and 2 deletions

2
.bleep
View file

@ -1 +1 @@
dad4171e22fa0f38c7dc19247c36f4004d1245de 8f4c536768b4ed3720cc4a6e651d0ed519aa6a60

View file

@ -237,7 +237,7 @@ take advantage of with single-line change.
```rust ```rust
fn main() { fn main() {
let mut my_server = Server::new(Some(Opt::default())).unwrap(); let mut my_server = Server::new(Some(Opt::parse_args())).unwrap();
... ...
} }
``` ```

View file

@ -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)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;