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 {
|
if options.test_print {
|
||||||
println!(
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub struct Options {
|
||||||
pub colors_use_overlay: bool,
|
pub colors_use_overlay: bool,
|
||||||
pub june: bool,
|
pub june: bool,
|
||||||
pub debug: bool,
|
pub debug: bool,
|
||||||
pub test_distro: Option<String>,
|
pub distro: Option<String>,
|
||||||
pub ascii_file: Option<PathBuf>,
|
pub ascii_file: Option<PathBuf>,
|
||||||
pub test_print: bool,
|
pub test_print: bool,
|
||||||
pub ask_exit: bool,
|
pub ask_exit: bool,
|
||||||
|
@ -103,7 +103,7 @@ BACKEND={{{}}}",
|
||||||
.help("Test for a specific distro")
|
.help("Test for a specific distro")
|
||||||
.argument("DISTRO")
|
.argument("DISTRO")
|
||||||
.optional();
|
.optional();
|
||||||
let test_distro = construct!([distro, test_distro]);
|
let distro = construct!([distro, test_distro]);
|
||||||
let ascii_file = long("ascii-file")
|
let ascii_file = long("ascii-file")
|
||||||
.help("Use a specific file for the ascii art")
|
.help("Use a specific file for the ascii art")
|
||||||
.argument("ASCII_FILE");
|
.argument("ASCII_FILE");
|
||||||
|
@ -131,7 +131,7 @@ BACKEND={{{}}}",
|
||||||
colors_use_overlay,
|
colors_use_overlay,
|
||||||
june,
|
june,
|
||||||
debug,
|
debug,
|
||||||
test_distro,
|
distro,
|
||||||
ascii_file,
|
ascii_file,
|
||||||
// hidden
|
// hidden
|
||||||
test_print,
|
test_print,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::process::ExitStatusExt as _;
|
use std::os::unix::process::ExitStatusExt as _;
|
||||||
|
@ -44,16 +45,21 @@ pub fn get_command_path() -> Result<PathBuf> {
|
||||||
Err(anyhow!("neofetch command not found"))
|
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")]
|
#[tracing::instrument(level = "debug")]
|
||||||
pub fn get_distro_ascii(distro: Option<String>) -> Result<String> {
|
pub fn get_distro_ascii<S>(distro: Option<S>) -> Result<String>
|
||||||
// TODO
|
where
|
||||||
|
S: AsRef<str> + fmt::Debug,
|
||||||
let distro = if let Some(distro) = distro {
|
{
|
||||||
distro
|
let distro: Cow<_> = if let Some(distro) = distro.as_ref() {
|
||||||
|
distro.as_ref().into()
|
||||||
} else {
|
} 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!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue