Fix distro overriding
This commit is contained in:
parent
e3b220a248
commit
974c4514b2
3 changed files with 17 additions and 11 deletions
|
@ -15,7 +15,7 @@ fn main() -> Result<()> {
|
|||
if options.test_print {
|
||||
println!(
|
||||
"{}",
|
||||
get_distro_ascii(None).context("Failed to get distro ascii")?
|
||||
get_distro_ascii(options.distro.as_ref()).context("Failed to get distro ascii")?
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct Options {
|
|||
pub colors_use_overlay: bool,
|
||||
pub june: bool,
|
||||
pub debug: bool,
|
||||
pub test_distro: Option<String>,
|
||||
pub distro: Option<String>,
|
||||
pub ascii_file: Option<PathBuf>,
|
||||
pub test_print: bool,
|
||||
pub ask_exit: bool,
|
||||
|
@ -103,7 +103,7 @@ BACKEND={{{}}}",
|
|||
.help("Test for a specific distro")
|
||||
.argument("DISTRO")
|
||||
.optional();
|
||||
let test_distro = construct!([distro, test_distro]);
|
||||
let distro = construct!([distro, test_distro]);
|
||||
let ascii_file = long("ascii-file")
|
||||
.help("Use a specific file for the ascii art")
|
||||
.argument("ASCII_FILE");
|
||||
|
@ -131,7 +131,7 @@ BACKEND={{{}}}",
|
|||
colors_use_overlay,
|
||||
june,
|
||||
debug,
|
||||
test_distro,
|
||||
distro,
|
||||
ascii_file,
|
||||
// hidden
|
||||
test_print,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::borrow::Cow;
|
||||
use std::ffi::OsStr;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::process::ExitStatusExt as _;
|
||||
|
@ -44,16 +45,21 @@ pub fn get_command_path() -> Result<PathBuf> {
|
|||
Err(anyhow!("neofetch command not found"))
|
||||
}
|
||||
|
||||
/// Gets the distro ascii of the current distro. Or if distro is specified, get
|
||||
/// the specific distro's ascii art instead.
|
||||
#[tracing::instrument(level = "debug")]
|
||||
pub fn get_distro_ascii(distro: Option<String>) -> Result<String> {
|
||||
// TODO
|
||||
|
||||
let distro = if let Some(distro) = distro {
|
||||
distro
|
||||
pub fn get_distro_ascii<S>(distro: Option<S>) -> Result<String>
|
||||
where
|
||||
S: AsRef<str> + fmt::Debug,
|
||||
{
|
||||
let distro: Cow<_> = if let Some(distro) = distro.as_ref() {
|
||||
distro.as_ref().into()
|
||||
} else {
|
||||
get_distro_name().context("Failed to get distro name")?
|
||||
get_distro_name()
|
||||
.context("Failed to get distro name")?
|
||||
.into()
|
||||
};
|
||||
debug!(distro, "resolved distro name");
|
||||
debug!(%distro, "distro name");
|
||||
|
||||
todo!()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue