conditionally remove cli args according to enabled feature

This commit is contained in:
Riccardo Casatta 2020-11-17 14:27:32 +01:00
parent 2f39a19b01
commit 3c8b8e4fca
No known key found for this signature in database
GPG Key ID: FD986A969E450397

View File

@ -309,7 +309,7 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> {
} }
pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
app.arg( let mut app = app.arg(
Arg::with_name("network") Arg::with_name("network")
.short("n") .short("n")
.long("network") .long("network")
@ -328,23 +328,6 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
.takes_value(true) .takes_value(true)
.default_value("main"), .default_value("main"),
) )
.arg(
Arg::with_name("server")
.short("s")
.long("server")
.value_name("SERVER:PORT")
.help("Sets the Electrum server to use")
.takes_value(true)
.default_value("ssl://electrum.blockstream.info:60002"),
)
.arg(
Arg::with_name("esplora")
.short("e")
.long("esplora")
.value_name("ESPLORA")
.help("Use the esplora server if given as parameter")
.takes_value(true),
)
.arg( .arg(
Arg::with_name("proxy") Arg::with_name("proxy")
.short("p") .short("p")
@ -375,8 +358,32 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
.short("v") .short("v")
.multiple(true) .multiple(true)
.help("Sets the level of verbosity"), .help("Sets the level of verbosity"),
) );
.subcommand(SubCommand::with_name("repl").about("Opens an interactive shell"))
if cfg!(feature = "esplora") {
app = app.arg(
Arg::with_name("esplora")
.short("e")
.long("esplora")
.value_name("ESPLORA")
.help("Use the esplora server if given as parameter")
.takes_value(true),
);
}
if cfg!(feature = "electrum") {
app = app.arg(
Arg::with_name("server")
.short("s")
.long("server")
.value_name("SERVER:PORT")
.help("Sets the Electrum server to use")
.takes_value(true)
.default_value("ssl://electrum.blockstream.info:60002"),
);
}
app.subcommand(SubCommand::with_name("repl").about("Opens an interactive shell"))
} }
#[maybe_async] #[maybe_async]