Skip to content

Commit

Permalink
feat: add additional environment and dependency info in yazi --debug (
Browse files Browse the repository at this point in the history
#1896)

Co-authored-by: sxyazi <[email protected]>
  • Loading branch information
realcathode and sxyazi committed Nov 10, 2024
1 parent a9a8a19 commit fd8871d
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 35 deletions.
45 changes: 32 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
@@ -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"}
6 changes: 3 additions & 3 deletions nix/yazi-unwrapped.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion yazi-boot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] }
10 changes: 9 additions & 1 deletion yazi-boot/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;

Expand Down
38 changes: 24 additions & 14 deletions yazi-boot/src/actions/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))?;
Expand Down Expand Up @@ -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!(
Expand All @@ -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"))?;
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion yazi-boot/src/actions/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
12 changes: 12 additions & 0 deletions yazi-boot/src/actions/rustc.rs
Original file line number Diff line number Diff line change
@@ -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")
)
}
}
12 changes: 12 additions & 0 deletions yazi-boot/src/actions/triple.rs
Original file line number Diff line number Diff line change
@@ -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
)
}
}

0 comments on commit fd8871d

Please sign in to comment.