tmux_interface/options/session/builder/local/
set_local_session_option.rs1use crate::options::{SetOptionTr, SetSessionOptionTr, SetUserOption};
2use crate::{SetOption, TmuxCommand};
3use std::borrow::Cow;
4
5pub struct SetLocalSessionOption;
6
7impl SetOptionTr for SetLocalSessionOption {
8 fn set_ext<'a, U: Into<Cow<'a, str>>, T: Into<Cow<'a, str>>, S: Into<Cow<'a, str>>>(
10 target: Option<U>,
11 name: T,
12 value: Option<S>,
13 ) -> TmuxCommand<'a> {
14 let cmd = SetOption::new().option(name);
15 let cmd = match target {
16 #[cfg(all(feature = "tmux_1_2", not(feature = "tmux_3_0")))]
17 Some(target) => cmd.target(target),
18 #[cfg(feature = "tmux_3_0")]
19 Some(target) => cmd.target_pane(target),
20 None => cmd,
21 };
22 let cmd = match value {
23 Some(value) => cmd.value(value),
24 None => cmd.unset(),
25 };
26 cmd.build()
27 }
28
29 fn unset_ext<'a, S: Into<Cow<'a, str>>, T: Into<Cow<'a, str>>>(
30 target: Option<S>,
31 name: T,
32 ) -> TmuxCommand<'a> {
33 let cmd = SetOption::new().option(name).unset();
34 let cmd = match target {
35 #[cfg(all(feature = "tmux_1_2", not(feature = "tmux_3_0")))]
36 Some(target) => cmd.target(target),
37 #[cfg(feature = "tmux_3_0")]
38 Some(target) => cmd.target_pane(target),
39 None => cmd,
40 };
41 cmd.build()
42 }
43}
44
45impl SetSessionOptionTr for SetLocalSessionOption {}
46
47impl SetUserOption for SetLocalSessionOption {}