mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add a bunch of new debugging information to yazi --debug (#824)
This commit is contained in:
parent
ca49a2d70b
commit
955e8f59a9
3 changed files with 67 additions and 47 deletions
|
|
@ -22,6 +22,7 @@ pub enum Emulator {
|
||||||
Hyper,
|
Hyper,
|
||||||
Mintty,
|
Mintty,
|
||||||
Neovim,
|
Neovim,
|
||||||
|
Apple,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Emulator {
|
impl Emulator {
|
||||||
|
|
@ -40,6 +41,7 @@ impl Emulator {
|
||||||
Self::Hyper => vec![Adaptor::Iterm2, Adaptor::Sixel],
|
Self::Hyper => vec![Adaptor::Iterm2, Adaptor::Sixel],
|
||||||
Self::Mintty => vec![Adaptor::Iterm2],
|
Self::Mintty => vec![Adaptor::Iterm2],
|
||||||
Self::Neovim => vec![],
|
Self::Neovim => vec![],
|
||||||
|
Self::Apple => vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -74,6 +76,7 @@ impl Emulator {
|
||||||
"Tabby" => return Self::Tabby,
|
"Tabby" => return Self::Tabby,
|
||||||
"Hyper" => return Self::Hyper,
|
"Hyper" => return Self::Hyper,
|
||||||
"mintty" => return Self::Mintty,
|
"mintty" => return Self::Mintty,
|
||||||
|
"Apple_Terminal" => return Self::Apple,
|
||||||
_ => warn!("[Adaptor] Unknown TERM_PROGRAM: {program}"),
|
_ => warn!("[Adaptor] Unknown TERM_PROGRAM: {program}"),
|
||||||
}
|
}
|
||||||
match term.as_str() {
|
match term.as_str() {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{env, ffi::OsString, path::{Path, PathBuf}, process};
|
use std::{env, ffi::OsString, fmt::Write, path::{Path, PathBuf}, process};
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
@ -33,64 +33,82 @@ impl Boot {
|
||||||
(parent.unwrap().to_owned(), Some(entry.file_name().unwrap().to_owned()))
|
(parent.unwrap().to_owned(), Some(entry.file_name().unwrap().to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn action_version() {
|
fn action_version() -> String {
|
||||||
println!(
|
format!(
|
||||||
"yazi {} ({} {})",
|
"{} ({} {})",
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
env!("VERGEN_GIT_SHA"),
|
env!("VERGEN_GIT_SHA"),
|
||||||
env!("VERGEN_BUILD_DATE")
|
env!("VERGEN_BUILD_DATE")
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn action_debug() {
|
fn action_debug() -> Result<String, std::fmt::Error> {
|
||||||
print!("Yazi\n ");
|
use std::{env::consts::{ARCH, FAMILY, OS}, process::Command};
|
||||||
Self::action_version();
|
let mut s = String::new();
|
||||||
|
|
||||||
println!("\nEnvironment");
|
writeln!(s, "\nYazi")?;
|
||||||
println!(
|
writeln!(s, " Version: {}", Self::action_version())?;
|
||||||
" OS: {}-{} ({})",
|
writeln!(s, " OS: {}-{} ({})", OS, ARCH, FAMILY)?;
|
||||||
std::env::consts::OS,
|
writeln!(s, " Debug: {}", cfg!(debug_assertions))?;
|
||||||
std::env::consts::ARCH,
|
|
||||||
std::env::consts::FAMILY
|
|
||||||
);
|
|
||||||
println!(" Debug: {}", cfg!(debug_assertions));
|
|
||||||
|
|
||||||
println!("\nEmulator");
|
writeln!(s, "\nEmulator")?;
|
||||||
println!(" Emulator.via_env: {:?}", yazi_adaptor::Emulator::via_env());
|
writeln!(s, " Emulator.via_env: {:?}", yazi_adaptor::Emulator::via_env())?;
|
||||||
println!(" Emulator.via_csi: {:?}", yazi_adaptor::Emulator::via_csi());
|
writeln!(s, " Emulator.via_csi: {:?}", yazi_adaptor::Emulator::via_csi())?;
|
||||||
println!(" Emulator.detect: {:?}", yazi_adaptor::Emulator::detect());
|
writeln!(s, " Emulator.detect: {:?}", yazi_adaptor::Emulator::detect())?;
|
||||||
|
|
||||||
println!("\nAdaptor");
|
writeln!(s, "\nAdaptor")?;
|
||||||
println!(" Adaptor.matches: {:?}", yazi_adaptor::Adaptor::matches());
|
writeln!(s, " Adaptor.matches: {:?}", yazi_adaptor::Adaptor::matches())?;
|
||||||
|
|
||||||
println!("\ntmux");
|
writeln!(s, "\nDesktop")?;
|
||||||
println!(" TMUX: {:?}", *yazi_adaptor::TMUX);
|
writeln!(s, " XDG_SESSION_TYPE: {:?}", env::var_os("XDG_SESSION_TYPE"))?;
|
||||||
|
writeln!(s, " WAYLAND_DISPLAY: {:?}", env::var_os("WAYLAND_DISPLAY"))?;
|
||||||
|
writeln!(s, " DISPLAY: {:?}", env::var_os("DISPLAY"))?;
|
||||||
|
|
||||||
println!("\nZellij");
|
writeln!(s, "\nSSH")?;
|
||||||
println!(" ZELLIJ_SESSION_NAME: {:?}", env::var_os("ZELLIJ_SESSION_NAME"));
|
writeln!(s, " shared.in_ssh_connection: {:?}", yazi_shared::in_ssh_connection())?;
|
||||||
|
|
||||||
println!("\nDesktop");
|
writeln!(s, "\nWSL")?;
|
||||||
println!(" XDG_SESSION_TYPE: {:?}", env::var_os("XDG_SESSION_TYPE"));
|
writeln!(
|
||||||
println!(" WAYLAND_DISPLAY: {:?}", env::var_os("WAYLAND_DISPLAY"));
|
s,
|
||||||
println!(" DISPLAY: {:?}", env::var_os("DISPLAY"));
|
|
||||||
|
|
||||||
println!("\nUeberzug++");
|
|
||||||
println!(
|
|
||||||
" Version: {:?}",
|
|
||||||
std::process::Command::new("ueberzugpp").arg("--version").output()
|
|
||||||
);
|
|
||||||
|
|
||||||
println!("\nWSL");
|
|
||||||
println!(
|
|
||||||
" /proc/sys/fs/binfmt_misc/WSLInterop: {:?}",
|
" /proc/sys/fs/binfmt_misc/WSLInterop: {:?}",
|
||||||
std::fs::symlink_metadata("/proc/sys/fs/binfmt_misc/WSLInterop").is_ok()
|
std::fs::symlink_metadata("/proc/sys/fs/binfmt_misc/WSLInterop").is_ok()
|
||||||
);
|
)?;
|
||||||
|
|
||||||
println!("\n\n--------------------------------------------------");
|
writeln!(s, "\nVariables")?;
|
||||||
println!(
|
writeln!(s, " EDITOR: {:?}", env::var_os("EDITOR"))?;
|
||||||
|
writeln!(s, " ZELLIJ_SESSION_NAME: {:?}", env::var_os("ZELLIJ_SESSION_NAME"))?;
|
||||||
|
writeln!(s, " YAZI_FILE_ONE: {:?}", env::var_os("YAZI_FILE_ONE"))?;
|
||||||
|
writeln!(s, " YAZI_CONFIG_HOME: {:?}", env::var_os("YAZI_CONFIG_HOME"))?;
|
||||||
|
|
||||||
|
writeln!(s, "\nfile(1)")?;
|
||||||
|
writeln!(
|
||||||
|
s,
|
||||||
|
" Version: {:?}",
|
||||||
|
Command::new(env::var_os("YAZI_FILE_TWO").unwrap_or("file".into())).arg("--version").output()
|
||||||
|
)?;
|
||||||
|
|
||||||
|
writeln!(s, "\nText Opener")?;
|
||||||
|
writeln!(
|
||||||
|
s,
|
||||||
|
" default: {:?}",
|
||||||
|
yazi_config::OPEN.openers("f75a.txt", "text/plain").and_then(|a| a.first().cloned())
|
||||||
|
)?;
|
||||||
|
writeln!(s, " block: {:?}", yazi_config::OPEN.block_opener("bulk.txt", "text/plain"))?;
|
||||||
|
|
||||||
|
writeln!(s, "\ntmux")?;
|
||||||
|
writeln!(s, " TMUX: {:?}", *yazi_adaptor::TMUX)?;
|
||||||
|
|
||||||
|
writeln!(s, "\nUeberzug++")?;
|
||||||
|
writeln!(s, " Version: {:?}", Command::new("ueberzugpp").arg("--version").output())?;
|
||||||
|
|
||||||
|
writeln!(s, "\n\n--------------------------------------------------")?;
|
||||||
|
writeln!(
|
||||||
|
s,
|
||||||
"When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time."
|
"When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time."
|
||||||
);
|
)?;
|
||||||
println!("You can find it in the {:?} directory.", Xdg::state_dir());
|
writeln!(s, "You can find it in the {:?} directory.", Xdg::state_dir())?;
|
||||||
|
|
||||||
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn action_clear_cache() {
|
fn action_clear_cache() {
|
||||||
|
|
@ -131,12 +149,12 @@ impl Default for Args {
|
||||||
let args = Self::parse();
|
let args = Self::parse();
|
||||||
|
|
||||||
if args.debug {
|
if args.debug {
|
||||||
Boot::action_debug();
|
println!("{}", Boot::action_debug().unwrap());
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.version {
|
if args.version {
|
||||||
Boot::action_version();
|
println!("Yazi {}", Boot::action_version());
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn env_exists(name: &str) -> bool { std::env::var_os(name).is_some_and(|s| !s.is_empty()) }
|
pub fn env_exists(name: &str) -> bool { std::env::var_os(name).is_some_and(|s| !s.is_empty()) }
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn in_ssh_connection() -> bool {
|
pub fn in_ssh_connection() -> bool {
|
||||||
env_exists("SSH_CLIENT") || env_exists("SSH_TTY") || env_exists("SSH_CONNECTION")
|
env_exists("SSH_CLIENT") || env_exists("SSH_TTY") || env_exists("SSH_CONNECTION")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue