]> Untitled Git - bdk-cli/commitdiff
conditionally remove cli args according to enabled feature
authorRiccardo Casatta <riccardo@casatta.it>
Tue, 17 Nov 2020 13:27:32 +0000 (14:27 +0100)
committerRiccardo Casatta <riccardo@casatta.it>
Tue, 17 Nov 2020 14:00:18 +0000 (15:00 +0100)
src/cli.rs

index f60f7932f464f752650fe1412e17332301e17e90..de56e87e751d09a33f8fba73617296ae09a15358 100644 (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> {
-    app.arg(
+    let mut app = app.arg(
         Arg::with_name("network")
             .short("n")
             .long("network")
@@ -328,23 +328,6 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
             .takes_value(true)
             .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::with_name("proxy")
             .short("p")
@@ -375,8 +358,32 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
             .short("v")
             .multiple(true)
             .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]