mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Use opt to limit passed values
This commit is contained in:
parent
db5823681f
commit
f3b5dcf125
2 changed files with 19 additions and 5 deletions
|
|
@ -1,12 +1,26 @@
|
||||||
use yazi_shared::event::CmdCow;
|
use yazi_shared::event::CmdCow;
|
||||||
|
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks, manager::commands::quit};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct Opt {
|
||||||
|
no_cwd_file: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<()> for Opt {
|
||||||
|
fn from(_: ()) -> Self { Self::default() }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CmdCow> for Opt {
|
||||||
|
fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }
|
||||||
|
}
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
pub fn close(&mut self, c: CmdCow, tasks: &Tasks) {
|
#[yazi_codegen::command]
|
||||||
|
pub fn close(&mut self, opt: Opt, tasks: &Tasks) {
|
||||||
if self.tabs.len() > 1 {
|
if self.tabs.len() > 1 {
|
||||||
return self.tabs.close(self.tabs.cursor);
|
return self.tabs.close(self.tabs.cursor);
|
||||||
}
|
}
|
||||||
self.quit(c, tasks);
|
self.quit(quit::Opt{ no_cwd_file: opt.no_cwd_file }, tasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ use yazi_shared::event::{CmdCow, EventQuit};
|
||||||
use crate::{manager::Manager, tasks::Tasks};
|
use crate::{manager::Manager, tasks::Tasks};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Opt {
|
pub struct Opt {
|
||||||
no_cwd_file: bool,
|
pub no_cwd_file: bool,
|
||||||
}
|
}
|
||||||
impl From<()> for Opt {
|
impl From<()> for Opt {
|
||||||
fn from(_: ()) -> Self { Self::default() }
|
fn from(_: ()) -> Self { Self::default() }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue