diff --git a/CHANGELOG.md b/CHANGELOG.md index d46757c..7b24457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ Dates are given in YYYY-MM-DD format. - Fixed PowerShell output regression introduced in v0.2.13, whoops #### Other - Nicer version output: `fif -V` reports "fif v0.3.2" (instead of just "fif 0.3.2" without the "v"), and `fif --version` - reports `fif v0.3.2 (XDG-Mime backend)`, or whatever backend you're using. + reports `fif v0.3.2 (XDG-Mime backend)`, or whatever backend you're using +- fif's trace output now includes its version, backend, operating system, and architecture ### v0.3.1 (2021-07-06) #### Features diff --git a/src/main.rs b/src/main.rs index a6e672a..369238e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,7 @@ use crate::formats::{Format, PowerShell, Shell}; use crate::mime_db::MimeDb; use crate::parameters::{OutputFormat, ScanOpts}; use std::collections::BTreeSet; +use crate::utils::{clap_long_version, os_name}; mod findings; mod formats; @@ -71,7 +72,7 @@ fn main() { // .target(env_logger::Target::Stdout) // log to stdout rather than stderr .init(); - // trace!("fif {}", CLAP_LONG_VERSION.get().unwrap()); + trace!("fif {}, running on {} {}", clap_long_version(), std::env::consts::ARCH, os_name()); trace!("Initialise mimetype database"); init_db(); diff --git a/src/utils.rs b/src/utils.rs index 946c0b9..6db4143 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -30,3 +30,23 @@ pub fn clap_version() -> &'static str { CLAP_VERSION.get_or_init(|| format!("v{} pub fn clap_long_version() -> &'static str { CLAP_LONG_VERSION.get_or_init(|| format!("v{} ({} backend)", VERSION.unwrap_or("???"), BACKEND)) } + +/// Returns the name of the target operating system, like "Windows" or "macOS". Won't account for things like Wine or +/// Linuxulator. +pub fn os_name() -> String { + use std::env::consts::OS; + match OS { + "ios" => "iOS".into(), + "macos" => "macOS".into(), + "freebsd" => "FreeBSD".into(), + "openbsd" => "OpenBSD".into(), + "netbsd" => "NetBSD".into(), + "vxworks" => "VxWorks".into(), + _ => { + // generic case: return consts::OS with the first letter in uppercase ("linux" -> "Linux") + let mut os_upper = String::from(OS); + os_upper.get_mut(0..1).map(|first| first.make_ascii_uppercase()); + os_upper + } + } +}