From a005c4047b96298700fb68412e9ab512f7ef6034 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 8 Aug 2022 23:09:11 +0200 Subject: vtcol: fix conditional code --- src/vtcol.rs | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/vtcol.rs b/src/vtcol.rs index feb8f0b..baf5ae3 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -254,6 +254,7 @@ enum ColorJob /** Dump a scheme. */ Dump(Scheme), /** Launch scheme editor. */ + #[cfg(feature = "gui")] Edit(Option, Scheme), /** Switch to color scheme. */ Set(Scheme), @@ -271,6 +272,7 @@ impl Run for ColorJob { match self { Self::Dump(scm) => Self::dump(scm), + #[cfg(feature = "gui")] Self::Edit(name, scm) => Self::edit(name, scm), Self::List => Self::list(), Self::Set(scm) => Self::set(console, scm), @@ -335,16 +337,6 @@ impl ColorJob editor.run() } - #[cfg(not(feature = "gui"))] - fn edit(scm: Scheme) -> Result<()> - { - eprintln!( - "scheme editor not available; try recompiling vtcol with \ - --features=gui!" - ); - Err(anyhow!("editor not available")) - } - fn set(con: Option, scheme: Scheme) -> Result<()> { let fd = open_console(con.as_deref())?; @@ -842,10 +834,13 @@ impl<'a> Job )) } #[cfg(not(feature = "gui"))] - Err(anyhow!( - "the ``edit'' subcommand requires vtcol to be \ - built with the the ``gui'' feature" - )) + { + let _ = subm; /* silence warn(unused_variables) */ + Err(anyhow!( + "the ``edit'' subcommand requires vtcol to be \ + built with the the ``gui'' feature" + )) + } }, ("list", _) => Ok(Self(con, Subcmd::Colors(ColorJob::List))), @@ -1016,14 +1011,13 @@ impl<'a> Job )); } - let target = - if subm.is_present("both") { - FlagTarget::Both - } else if subm.is_present("dflt") { - FlagTarget::Default - } else { - FlagTarget::Current - }; + let target = if subm.is_present("both") { + FlagTarget::Both + } else if subm.is_present("dflt") { + FlagTarget::Default + } else { + FlagTarget::Current + }; let cap = subm.value_of("caps").map(|a| a == "on"); -- cgit v1.2.3