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
use crate::error::Error;
use crate::tmux_interface::*;
use std::process::Output;

impl<'a> TmuxInterface<'a> {
    #[cfg(not(feature = "use_cmd_alias"))]
    const LOCK_CLIENT: &'static str = "lock-client";
    #[cfg(feature = "use_cmd_alias")]
    const LOCK_CLIENT: &'static str = "lockc";

    /// Lock `target-client`
    ///
    /// # Manual
    ///
    /// tmux ^1.1:
    /// ```text
    /// tmux lock-client [-t target-client]
    /// (alias: lockc)
    /// ```
    pub fn lock_client(&mut self, target_client: Option<&str>) -> Result<Output, Error> {
        let mut args: Vec<&str> = Vec::new();
        if let Some(s) = target_client {
            args.extend_from_slice(&[t_KEY, s])
        }
        let output = self.command(TmuxInterface::LOCK_CLIENT, &args)?;
        Ok(output)
    }
}