From fd8871d87859b13bb8038862350000fd132e0da3 Mon Sep 17 00:00:00 2001 From: Ion Date: Sun, 10 Nov 2024 16:50:31 +0200 Subject: [PATCH] feat: add additional environment and dependency info in `yazi --debug` (#1896) Co-authored-by: sxyazi --- Cargo.lock | 45 +++++++++++++++++++++++---------- Cargo.toml | 2 +- cspell.json | 2 +- nix/yazi-unwrapped.nix | 6 ++--- yazi-boot/Cargo.toml | 2 +- yazi-boot/build.rs | 10 +++++++- yazi-boot/src/actions/debug.rs | 38 ++++++++++++++++++---------- yazi-boot/src/actions/mod.rs | 2 +- yazi-boot/src/actions/rustc.rs | 12 +++++++++ yazi-boot/src/actions/triple.rs | 12 +++++++++ 10 files changed, 96 insertions(+), 35 deletions(-) create mode 100644 yazi-boot/src/actions/rustc.rs create mode 100644 yazi-boot/src/actions/triple.rs diff --git a/Cargo.lock b/Cargo.lock index 45687e29..7a93671c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/Cargo.toml b/Cargo.toml index 343920de..c4def733 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/cspell.json b/cspell.json index b37b595d..5d3663bc 100644 --- a/cspell.json +++ b/cspell.json @@ -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":[]} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/nix/yazi-unwrapped.nix b/nix/yazi-unwrapped.nix index b4c7cc19..753c9375 100644 --- a/nix/yazi-unwrapped.nix +++ b/nix/yazi-unwrapped.nix @@ -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 = { diff --git a/yazi-boot/Cargo.toml b/yazi-boot/Cargo.toml index 1ffad753..57edcace 100644 --- a/yazi-boot/Cargo.toml +++ b/yazi-boot/Cargo.toml @@ -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" ] } diff --git a/yazi-boot/build.rs b/yazi-boot/build.rs index c84a976c..0bf01ae0 100644 --- a/yazi-boot/build.rs +++ b/yazi-boot/build.rs @@ -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> { 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()?; diff --git a/yazi-boot/src/actions/debug.rs b/yazi-boot/src/actions/debug.rs index c0dc4e1d..e5859d6e 100644 --- a/yazi-boot/src/actions/debug.rs +++ b/yazi-boot/src/actions/debug.rs @@ -8,13 +8,12 @@ use super::Actions; impl Actions { pub(super) fn debug() -> Result { - 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 { diff --git a/yazi-boot/src/actions/mod.rs b/yazi-boot/src/actions/mod.rs index 6a323541..4f7b0221 100644 --- a/yazi-boot/src/actions/mod.rs +++ b/yazi-boot/src/actions/mod.rs @@ -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); diff --git a/yazi-boot/src/actions/rustc.rs b/yazi-boot/src/actions/rustc.rs new file mode 100644 index 00000000..834ba6e5 --- /dev/null +++ b/yazi-boot/src/actions/rustc.rs @@ -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") + ) + } +} diff --git a/yazi-boot/src/actions/triple.rs b/yazi-boot/src/actions/triple.rs new file mode 100644 index 00000000..04dafcfc --- /dev/null +++ b/yazi-boot/src/actions/triple.rs @@ -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 + ) + } +}