use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
pub type RenameW<'a> = RenameWindow<'a>;
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct RenameWindow<'a> {
#[cfg(feature = "tmux_0_8")]
pub target_window: Option<Cow<'a, str>>,
#[cfg(feature = "tmux_0_8")]
pub new_name: Option<Cow<'a, str>>,
}
impl<'a> RenameWindow<'a> {
pub fn new() -> Self {
Default::default()
}
#[cfg(feature = "tmux_0_8")]
pub fn target_window<S: Into<Cow<'a, str>>>(mut self, target_window: S) -> Self {
self.target_window = Some(target_window.into());
self
}
#[cfg(feature = "tmux_0_8")]
pub fn new_name<S: Into<Cow<'a, str>>>(mut self, new_name: S) -> Self {
self.new_name = Some(new_name.into());
self
}
pub fn build(self) -> TmuxCommand<'a> {
let mut cmd = TmuxCommand::new();
cmd.name(RENAME_WINDOW);
#[cfg(feature = "tmux_0_8")]
if let Some(target_window) = self.target_window {
cmd.push_option(T_LOWERCASE_KEY, target_window);
}
#[cfg(feature = "tmux_0_8")]
if let Some(new_name) = self.new_name {
cmd.push_param(new_name);
}
cmd
}
}