mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: don't require a TTY for --version
This commit is contained in:
parent
d9cd1907d9
commit
c3a6e78638
3 changed files with 15 additions and 6 deletions
|
|
@ -3,17 +3,20 @@ use std::process;
|
||||||
pub struct Actions;
|
pub struct Actions;
|
||||||
|
|
||||||
impl 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) {
|
pub(crate) fn act(args: &crate::Args) {
|
||||||
if args.debug {
|
if args.debug {
|
||||||
println!("{}", Self::debug().unwrap());
|
println!("{}", Self::debug().unwrap());
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.version {
|
|
||||||
println!("Yazi {}", Self::version());
|
|
||||||
process::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.clear_cache {
|
if args.clear_cache {
|
||||||
Self::clear_cache();
|
Self::clear_cache();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,12 @@ use yazi_shim::cell::RoCell;
|
||||||
pub static ARGS: RoCell<Args> = RoCell::new();
|
pub static ARGS: RoCell<Args> = RoCell::new();
|
||||||
pub static BOOT: RoCell<Boot> = RoCell::new();
|
pub static BOOT: RoCell<Boot> = RoCell::new();
|
||||||
|
|
||||||
pub fn init() {
|
pub fn preflight() {
|
||||||
ARGS.with(<_>::parse);
|
ARGS.with(<_>::parse);
|
||||||
|
actions::Actions::act_early(&ARGS);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init() {
|
||||||
BOOT.init(<_>::from(&*ARGS));
|
BOOT.init(<_>::from(&*ARGS));
|
||||||
|
|
||||||
actions::Actions::act(&ARGS);
|
actions::Actions::act(&ARGS);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
Logs::start()?;
|
Logs::start()?;
|
||||||
_ = fdlimit::raise_fd_limit();
|
_ = fdlimit::raise_fd_limit();
|
||||||
|
|
||||||
|
yazi_boot::preflight();
|
||||||
|
|
||||||
yazi_tty::init();
|
yazi_tty::init();
|
||||||
|
|
||||||
yazi_term::init()?;
|
yazi_term::init()?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue