feat: add additional environment and dependency info in yazi --debug (#1896)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
Ion 2024-11-10 16:50:31 +02:00 committed by sxyazi
parent a9a8a190a4
commit fd8871d878
No known key found for this signature in database
10 changed files with 96 additions and 35 deletions

45
Cargo.lock generated
View File

@ -34,9 +34,9 @@ checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1"
[[package]]
name = "allocator-api2"
version = "0.2.18"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f"
[[package]]
name = "android-tzdata"
@ -327,9 +327,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.36"
version = "1.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70"
checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf"
dependencies = [
"jobserver",
"libc",
@ -1538,8 +1538,9 @@ dependencies = [
[[package]]
name = "mlua"
version = "0.10.0"
source = "git+https://github.com/mlua-rs/mlua.git#c7094d470ff377775ba267ea78650d095db9b017"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ae9546e4a268c309804e8bbb7526e31cbfdedca7cd60ac1b987d0b212e0d876"
dependencies = [
"anyhow",
"bstr",
@ -1557,8 +1558,9 @@ dependencies = [
[[package]]
name = "mlua-sys"
version = "0.6.4"
source = "git+https://github.com/mlua-rs/mlua.git#c7094d470ff377775ba267ea78650d095db9b017"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efa6bf1a64f06848749b7e7727417f4ec2121599e2a10ef0a8a3888b0e9a5a0d"
dependencies = [
"cc",
"cfg-if",
@ -1570,7 +1572,8 @@ dependencies = [
[[package]]
name = "mlua_derive"
version = "0.10.0"
source = "git+https://github.com/mlua-rs/mlua.git#c7094d470ff377775ba267ea78650d095db9b017"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cfc5faa2e0d044b3f5f0879be2920e0a711c97744c42cf1c295cb183668933e"
dependencies = [
"itertools 0.13.0",
"once_cell",
@ -2182,6 +2185,15 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "0.38.39"
@ -2222,6 +2234,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]]
name = "serde"
version = "1.0.214"
@ -2496,18 +2514,18 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "thiserror"
version = "1.0.68"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.68"
version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e"
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
dependencies = [
"proc-macro2",
"quote",
@ -2908,6 +2926,7 @@ checksum = "349ed9e45296a581f455bc18039878f409992999bc1d5da12a6800eb18c8752f"
dependencies = [
"anyhow",
"derive_builder",
"rustc_version",
"rustversion",
"time",
"vergen-lib",

View File

@ -21,7 +21,7 @@ futures = "0.3.31"
globset = "0.4.15"
libc = "0.2.162"
md-5 = "0.10.6"
mlua = { git = "https://github.com/mlua-rs/mlua.git", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] }
mlua = { version = "0.10.1", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] }
parking_lot = "0.12.3"
ratatui = { version = "0.29.0", features = [ "unstable-rendered-line-info" ] }
regex = "1.11.1"

View File

@ -1 +1 @@
{"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp"," Überzug"," Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind"],"version":"0.2","language":"en","flagWords":[]}
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp"," Überzug"," Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","Sysinfo"],"language":"en","version":"0.2"}

View File

@ -29,9 +29,9 @@ rustPlatform.buildRustPackage rec {
cargoLock = {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"mlua-0.10.0" = "sha256-Xg6/jc+UP8tbJJ6x1sbAgt8ZHt051xEBBcjmikQqYlw=";
};
#outputHashes = {
# "mlua-0.10.0" = "sha256-Xg6/jc+UP8tbJJ6x1sbAgt8ZHt051xEBBcjmikQqYlw=";
#};
};
env = {

View File

@ -24,4 +24,4 @@ clap = { workspace = true }
clap_complete = "4.5.37"
clap_complete_fig = "4.5.2"
clap_complete_nushell = "4.5.4"
vergen-gitcl = { version = "1.0.1", features = [ "build" ] }
vergen-gitcl = { version = "1.0.1", features = [ "build", "rustc" ] }

View File

@ -5,11 +5,19 @@ use std::{env, error::Error};
use clap::CommandFactory;
use clap_complete::{Shell, generate_to};
use vergen_gitcl::{BuildBuilder, Emitter, GitclBuilder};
use vergen_gitcl::{BuildBuilder, Emitter, GitclBuilder, RustcBuilder};
fn main() -> Result<(), Box<dyn Error>> {
Emitter::default()
.add_instructions(&BuildBuilder::default().build_date(true).build()?)?
.add_instructions(
&RustcBuilder::default()
.commit_date(true)
.commit_hash(true)
.host_triple(true)
.semver(true)
.build()?,
)?
.add_instructions(&GitclBuilder::default().commit_date(true).sha(true).build()?)?
.emit()?;

View File

@ -8,13 +8,12 @@ use super::Actions;
impl Actions {
pub(super) fn debug() -> Result<String, std::fmt::Error> {
use std::env::consts::{ARCH, FAMILY, OS};
let mut s = String::new();
writeln!(s, "\nYazi")?;
writeln!(s, " Version: {}", Self::version())?;
writeln!(s, " Debug : {}", cfg!(debug_assertions))?;
writeln!(s, " OS : {}-{} ({})", OS, ARCH, FAMILY)?;
writeln!(s, " Triple : {}", Self::triple())?;
writeln!(s, " Rustc : {}", Self::rustc())?;
writeln!(s, "\nYa")?;
writeln!(s, " Version: {}", Self::process_output("ya", "--version"))?;
@ -43,11 +42,13 @@ impl Actions {
writeln!(s, " WSL: {:?}", *yazi_adapter::WSL)?;
writeln!(s, "\nVariables")?;
writeln!(s, " SHELL : {:?}", env::var_os("SHELL"))?;
writeln!(s, " EDITOR : {:?}", env::var_os("EDITOR"))?;
writeln!(s, " VISUAL : {:?}", env::var_os("VISUAL"))?;
writeln!(s, " YAZI_FILE_ONE : {:?}", env::var_os("YAZI_FILE_ONE"))?;
writeln!(s, " YAZI_CONFIG_HOME : {:?}", env::var_os("YAZI_CONFIG_HOME"))?;
writeln!(s, " SHELL : {:?}", env::var_os("SHELL"))?;
writeln!(s, " EDITOR : {:?}", env::var_os("EDITOR"))?;
writeln!(s, " VISUAL : {:?}", env::var_os("VISUAL"))?;
writeln!(s, " YAZI_FILE_ONE : {:?}", env::var_os("YAZI_FILE_ONE"))?;
writeln!(s, " YAZI_CONFIG_HOME: {:?}", env::var_os("YAZI_CONFIG_HOME"))?;
writeln!(s, " YAZI_ZOXIDE_OPTS: {:?}", env::var_os("YAZI_ZOXIDE_OPTS"))?;
writeln!(s, " FZF_DEFAULT_OPTS: {:?}", env::var_os("FZF_DEFAULT_OPTS"))?;
writeln!(s, "\nText Opener")?;
writeln!(
@ -74,13 +75,11 @@ impl Actions {
writeln!(s, " Zellij version : {}", Self::process_output("zellij", "--version"))?;
writeln!(s, "\nDependencies")?;
writeln!(
s,
" file : {}",
Self::process_output(env::var_os("YAZI_FILE_ONE").unwrap_or("file".into()), "--version")
)?;
#[rustfmt::skip]
writeln!(s, " file : {}", Self::process_output(env::var_os("YAZI_FILE_ONE").unwrap_or("file".into()), "--version"))?;
writeln!(s, " ueberzugpp : {}", Self::process_output("ueberzugpp", "--version"))?;
writeln!(s, " ffmpegthumbnailer: {}", Self::process_output("ffmpegthumbnailer", "-v"))?;
writeln!(s, " pdftoppm : {}", Self::process_output("pdftoppm", "--help"))?;
writeln!(s, " magick : {}", Self::process_output("magick", "--version"))?;
writeln!(s, " fzf : {}", Self::process_output("fzf", "--version"))?;
writeln!(s, " fd : {}", Self::process_output("fd", "--version"))?;
@ -92,6 +91,12 @@ impl Actions {
writeln!(s, " 7zz : {}", Self::process_output("7zz", "i"))?;
writeln!(s, " jq : {}", Self::process_output("jq", "--version"))?;
writeln!(s, "\nClipboard")?;
#[rustfmt::skip]
writeln!(s, " wl-copy/paste: {} / {}", Self::process_output("wl-copy", "--version"), Self::process_output("wl-paste", "--version"))?;
writeln!(s, " xclip : {}", Self::process_output("xclip", "-version"))?;
writeln!(s, " xsel : {}", Self::process_output("xsel", "--version"))?;
writeln!(s, "\n\n--------------------------------------------------")?;
writeln!(
s,
@ -106,7 +111,12 @@ impl Actions {
match std::process::Command::new(&name).arg(arg).output() {
Ok(out) if out.status.success() => {
let line =
String::from_utf8_lossy(&out.stdout).trim().lines().next().unwrap_or_default().to_owned();
String::from_utf8_lossy(&if out.stdout.is_empty() { out.stderr } else { out.stdout })
.trim()
.lines()
.next()
.unwrap_or_default()
.to_owned();
if name.as_ref() == "ya" {
line.trim_start_matches("Ya ").to_owned()
} else {

View File

@ -1,3 +1,3 @@
#![allow(clippy::module_inception)]
yazi_macro::mod_flat!(actions clear_cache debug version);
yazi_macro::mod_flat!(actions clear_cache debug rustc triple version);

View File

@ -0,0 +1,12 @@
use super::Actions;
impl Actions {
pub(super) fn rustc() -> String {
format!(
"{} ({} {})",
env!("VERGEN_RUSTC_SEMVER"),
&env!("VERGEN_RUSTC_COMMIT_HASH")[..8],
env!("VERGEN_RUSTC_COMMIT_DATE")
)
}
}

View File

@ -0,0 +1,12 @@
use super::Actions;
impl Actions {
pub(super) fn triple() -> String {
format!(
"{} ({}-{})",
env!("VERGEN_RUSTC_HOST_TRIPLE"),
std::env::consts::OS,
std::env::consts::ARCH
)
}
}