blob: b12c01b92fdac6ba5770cb8f4cf24fa0630ce4e1 (
plain)
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
26
27
28
29
30
31
32
33
|
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ExternalExecutionMode {
/// executed in the parent shell, on broot leaving, using the `br` function
FromParentShell,
/// executed on broot leaving, not necessarly in the parent shell
LeaveBroot,
/// executed in a sub process without quitting broot
StayInBroot,
}
impl ExternalExecutionMode {
pub fn is_from_shell(self) -> bool {
matches!(self, Self::FromParentShell)
}
pub fn is_leave_broot(self) -> bool {
!matches!(self, Self::StayInBroot)
}
pub fn from_conf(
from_shell: Option<bool>, // default is false
leave_broot: Option<bool>, // default is true
) -> Self {
if from_shell.unwrap_or(false) {
Self::FromParentShell
} else if leave_broot.unwrap_or(true) {
Self::LeaveBroot
} else {
Self::StayInBroot
}
}
}
|