1 #[derive(Debug, Clone, Copy, PartialEq)]
2 pub enum ExternalExecutionMode {
3     /// executed in the parent shell, on broot leaving, using the `br` function
4     FromParentShell,
5 
6     /// executed on broot leaving, not necessarly in the parent shell
7     LeaveBroot,
8 
9     /// executed in a sub process without quitting broot
10     StayInBroot,
11 }
12 
13 impl ExternalExecutionMode {
is_from_shell(self) -> bool14     pub fn is_from_shell(self) -> bool {
15         matches!(self, Self::FromParentShell)
16     }
is_leave_broot(self) -> bool17     pub fn is_leave_broot(self) -> bool {
18         !matches!(self, Self::StayInBroot)
19     }
20 
from_conf( from_shell: Option<bool>, leave_broot: Option<bool>, ) -> Self21     pub fn from_conf(
22         from_shell: Option<bool>,  // default is false
23         leave_broot: Option<bool>, // default is true
24     ) -> Self {
25         if from_shell.unwrap_or(false) {
26             Self::FromParentShell
27         } else if leave_broot.unwrap_or(true) {
28             Self::LeaveBroot
29         } else {
30             Self::StayInBroot
31         }
32     }
33 }
34