diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-01-28 10:50:34 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-01-28 10:50:34 +0100 |
commit | 3b548e7a1bccde28dde3d4bbd59ccc2bd470db5c (patch) | |
tree | c7e405c6c6f676580dea06c6cfd7a45431b8e2c1 /sq | |
parent | bc469cb986512056a7abe175cb8cc69f003ede3a (diff) |
sq: Allow change of features in the cli at runtime.
- This will help in generating manpages for all combination of
features.
Diffstat (limited to 'sq')
-rw-r--r-- | sq/build.rs | 5 | ||||
-rw-r--r-- | sq/src/sq_cli.rs | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/sq/build.rs b/sq/build.rs index 3711838b..14818eee 100644 --- a/sq/build.rs +++ b/sq/build.rs @@ -13,7 +13,10 @@ fn main() { // XXX: Revisit once // https://github.com/rust-lang/rust/issues/44732 is stabilized. - let mut sq = sq_cli::configure(clap::App::new("sq").set_term_width(80)); + let mut sq = sq_cli::configure( + clap::App::new("sq").set_term_width(80), + cfg!(feature = "net"), + ); let mut main = fs::File::create("src/sq-usage.rs").unwrap(); dump_help(&mut main, &mut sq, diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs index 316beb10..7833a3bf 100644 --- a/sq/src/sq_cli.rs +++ b/sq/src/sq_cli.rs @@ -3,7 +3,9 @@ use clap::{App, Arg, ArgGroup, SubCommand, AppSettings}; pub fn build() -> App<'static, 'static> { - configure(App::new("sq")) + configure(App::new("sq"), + cfg!(feature = "net"), + ) } /// Defines the CLI. @@ -16,7 +18,10 @@ pub fn build() -> App<'static, 'static> { /// - Key discovery & networking (4xx) /// - Armor (5xx) /// - Inspection & packet manipulation (6xx) -pub fn configure(app: App<'static, 'static>) -> App<'static, 'static> { +pub fn configure( + app: App<'static, 'static>, + feature_net: bool, +) -> App<'static, 'static> { let version = Box::leak( format!("{} (sequoia-openpgp {})", env!("CARGO_PKG_VERSION"), @@ -1227,7 +1232,7 @@ $ sq packet join juliet.pgp-[0-3]* .short("B").long("binary") .help("Emits binary data")))); - let app = if ! cfg!(feature = "net") { + let app = if ! feature_net { // Without networking support. app } else { |