diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2022-08-08 23:09:11 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2022-08-08 23:10:37 +0200 |
commit | a005c4047b96298700fb68412e9ab512f7ef6034 (patch) | |
tree | 62f2e7b08c30539f7551f954503b07fb64cbd332 | |
parent | adc525cf75a08eef7aa96c7ca56eef5617becc06 (diff) | |
download | vtcol-a005c4047b96298700fb68412e9ab512f7ef6034.tar.gz |
vtcol: fix conditional code
-rw-r--r-- | src/vtcol.rs | 38 |
1 files 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<String>, 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<String>, 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"); |