yazi_core/manager/commands/
update_tasks.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use yazi_shared::{event::CmdCow, url::Url};

use crate::manager::Manager;

pub struct Opt {
	urls: Vec<Url>,
}

impl TryFrom<CmdCow> for Opt {
	type Error = ();

	fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
		Ok(Self { urls: c.take_any("urls").ok_or(())? })
	}
}

impl Manager {
	pub fn update_tasks(&mut self, opt: impl TryInto<Opt>) {
		let Ok(opt) = opt.try_into() else {
			return;
		};

		self.watcher.push_files(opt.urls);
	}
}