kode kleanup
This commit is contained in:
parent
6934dd0b5e
commit
0278fe252e
3 changed files with 7 additions and 15 deletions
|
@ -10,8 +10,8 @@ use cfg_if::cfg_if;
|
|||
use snailquote::escape;
|
||||
|
||||
use crate::findings::ScanError;
|
||||
use crate::utils::{VERSION, BACKEND};
|
||||
use crate::{Findings};
|
||||
use crate::utils::{BACKEND, VERSION};
|
||||
use crate::Findings;
|
||||
use itertools::Itertools;
|
||||
|
||||
/// A macro for creating an array of `Writable`s without needing to pepper your code with `into()`s.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! [Clap] struct used to parse command line arguments.
|
||||
|
||||
use crate::string_type::String as StringType;
|
||||
use crate::utils::{clap_version, clap_long_version};
|
||||
use crate::utils::{clap_long_version, clap_version};
|
||||
use cfg_if::cfg_if;
|
||||
use clap::{AppSettings, Clap};
|
||||
use std::collections::BTreeSet;
|
||||
|
|
16
src/utils.rs
16
src/utils.rs
|
@ -1,5 +1,5 @@
|
|||
use once_cell::sync::OnceCell;
|
||||
use cfg_if::cfg_if;
|
||||
use once_cell::sync::OnceCell;
|
||||
|
||||
/// The current version of fif, as defined in Cargo.toml.
|
||||
pub const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
|
||||
|
@ -23,18 +23,10 @@ static CLAP_LONG_VERSION: OnceCell<String> = OnceCell::new();
|
|||
|
||||
/// Sets [`CLAP_VERSION`] to be the version defined in Cargo.toml, prefixed with a v (e.g. "v0.3.1"), then returns it as
|
||||
/// a String.
|
||||
pub(crate) fn clap_version() -> &'static str {
|
||||
CLAP_VERSION
|
||||
.set(format!("v{}", VERSION.unwrap_or("???")))
|
||||
.unwrap_or_default(); // it doesn't matter if CLAP_VERSION has already been set
|
||||
CLAP_VERSION.get().unwrap().as_str()
|
||||
}
|
||||
pub fn clap_version() -> &'static str { CLAP_VERSION.get_or_init(|| format!("v{}", VERSION.unwrap_or("???"))) }
|
||||
|
||||
/// Sets [`CLAP_LONG_VERSION`] to be similar to [`CLAP_VERSION`], followed by the chosen backend in parentheses (e.g.
|
||||
/// "v0.3.1 (XDG-Mime backend)"), then returns it as a String.
|
||||
pub(crate) fn clap_long_version() -> &'static str {
|
||||
CLAP_LONG_VERSION
|
||||
.set(format!("v{} ({} backend)", VERSION.unwrap_or("???"), BACKEND))
|
||||
.unwrap_or_default();
|
||||
CLAP_LONG_VERSION.get().unwrap().as_str()
|
||||
pub fn clap_long_version() -> &'static str {
|
||||
CLAP_LONG_VERSION.get_or_init(|| format!("v{} ({} backend)", VERSION.unwrap_or("???"), BACKEND))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue