fix: don't require a TTY for --version

This commit is contained in:
SAY-5 2026-05-24 03:10:47 -07:00
parent d9cd1907d9
commit c3a6e78638
3 changed files with 15 additions and 6 deletions

View file

@ -3,17 +3,20 @@ use std::process;
pub struct Actions;
impl Actions {
// Actions that require no terminal/config initialization, handled before it.
pub(crate) fn act_early(args: &crate::Args) {
if args.version {
println!("Yazi {}", Self::version());
process::exit(0);
}
}
pub(crate) fn act(args: &crate::Args) {
if args.debug {
println!("{}", Self::debug().unwrap());
process::exit(0);
}
if args.version {
println!("Yazi {}", Self::version());
process::exit(0);
}
if args.clear_cache {
Self::clear_cache();
process::exit(0);

View file

@ -8,8 +8,12 @@ use yazi_shim::cell::RoCell;
pub static ARGS: RoCell<Args> = RoCell::new();
pub static BOOT: RoCell<Boot> = RoCell::new();
pub fn init() {
pub fn preflight() {
ARGS.with(<_>::parse);
actions::Actions::act_early(&ARGS);
}
pub fn init() {
BOOT.init(<_>::from(&*ARGS));
actions::Actions::act(&ARGS);

View file

@ -14,6 +14,8 @@ async fn main() -> anyhow::Result<()> {
Logs::start()?;
_ = fdlimit::raise_fd_limit();
yazi_boot::preflight();
yazi_tty::init();
yazi_term::init()?;