diff options
Diffstat (limited to 'src/run/builtin.rs')
| -rw-r--r-- | src/run/builtin.rs | 109 |
1 files changed, 59 insertions, 50 deletions
diff --git a/src/run/builtin.rs b/src/run/builtin.rs index c8224c0..b731b10 100644 --- a/src/run/builtin.rs +++ b/src/run/builtin.rs @@ -111,31 +111,6 @@ impl Builtin for clear { } } -/// restart shell -#[derive(Copy, Clone)] -pub struct re; -impl Builtin for re { - fn name(&self) -> &str { - "re" - } - - fn special(&mut self, session: Arc<Mutex<Session>>, _args: &[BString]) { - session.lock().unwrap().raw_disable(); - crate::reload::begin_reload(); - session.lock().unwrap().raw_enable(); // something went wrong, let's restore raw mode - } - - fn io( - &self, - _session: Arc<Mutex<Session>>, - _args: &[BString], - _stdin: &mut dyn Read, - _stdout: &mut dyn Write, - ) -> Result { - Ok(()) - } -} - #[derive(Copy, Clone)] pub struct Sink { name: &'static str, @@ -557,31 +532,6 @@ impl Builtin for unalias { } #[derive(Copy, Clone)] -pub struct debug; -impl Builtin for debug { - fn name(&self) -> &str { - "debug" - } - - fn io( - &self, - session: Arc<Mutex<Session>>, - args: &[BString], - _stdin: &mut dyn Read, - stdout: &mut dyn Write, - ) -> Result { - let mut se = session.lock().unwrap(); - for arg in args { - match &arg[..] { - b"keys" | b"keystrokes" => se.debug_keystrokes = !se.debug_keystrokes, - _ => writeln!(stdout, "debug: unknown option {}", arg.escape_ascii())?, - } - } - Ok(()) - } -} - -#[derive(Copy, Clone)] pub struct terminfo; impl Builtin for terminfo { fn name(&self) -> &str { @@ -988,3 +938,62 @@ impl Builtin for export { Ok(()) } } + +#[cfg(debug_assertions)] +mod dbg { + use super::*; + + #[derive(Copy, Clone)] + pub struct debug; + + impl Builtin for debug { + fn name(&self) -> &str { + "debug" + } + + fn io( + &self, + session: Arc<Mutex<Session>>, + args: &[BString], + _stdin: &mut dyn Read, + stdout: &mut dyn Write, + ) -> Result { + let mut se = session.lock().unwrap(); + for arg in args { + match &arg[..] { + b"keys" | b"keystrokes" => se.debug_keystrokes = !se.debug_keystrokes, + _ => writeln!(stdout, "debug: unknown option {}", arg.escape_ascii())?, + } + } + Ok(()) + } + } + + /// restart shell + #[derive(Copy, Clone)] + pub struct re; + impl Builtin for re { + fn name(&self) -> &str { + "re" + } + + fn special(&mut self, session: Arc<Mutex<Session>>, _args: &[BString]) { + session.lock().unwrap().raw_disable(); + crate::reload::begin_reload(); + session.lock().unwrap().raw_enable(); // something went wrong, let's restore raw mode + } + + fn io( + &self, + _session: Arc<Mutex<Session>>, + _args: &[BString], + _stdin: &mut dyn Read, + _stdout: &mut dyn Write, + ) -> Result { + Ok(()) + } + } +} + +#[cfg(debug_assertions)] +pub use dbg::{debug, re}; |
