Closed yonas closed 5 months ago
Looks like you can use structopt::flatten
I created a simple one to make sure it worked here 😅
use structopt::StructOpt;
#[derive(StructOpt)]
struct MyOpt {
#[structopt(short)]
something_cool: String,
#[structopt(flatten)]
base_opts: Opt
}
fn main() {
let my_opts = MyOpt::from_args();
let mut my_server = Server::new(Some(my_opts.base_opts)).unwrap();
Then if you run with -h
you get
my-prox 0.1.0
Commandline options
Call `Opt::from_args()` to build this object from the process's command line arguments.
USAGE:
my-prox [FLAGS] [OPTIONS] -s <something-cool>
FLAGS:
-d, --daemon Whether should run this server in the background
-h, --help Prints help information
--nocapture Not actually used. This flag is there so that the server is not upset seeing this flag passed
from `cargo test` sometimes
-t, --test Test the configuration and exit
-u, --upgrade Whether this server should try to upgrade from an running old server
-V, --version Prints version information
OPTIONS:
-c, --conf <conf> The path to the configuration file
-s <something-cool>
@johnhurt Thanks, it works!
Very helpful!
How can I add new CLI flags and config file settings without hacking on
pingora_core::server::configuration::Opt
directly?Should we be using a trait instead of directly referencing a fixed struct?