fix warns
This commit is contained in:
		
							parent
							
								
									d0c19f7947
								
							
						
					
					
						commit
						0174eeb4cc
					
				| 
						 | 
					@ -82,15 +82,6 @@ pub struct SetAttribute {
 | 
				
			||||||
    pub value: Attribute,
 | 
					    pub value: Attribute,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl SetAttribute {
 | 
					 | 
				
			||||||
    pub fn new<S: Into<String>>(path: S, value: Attribute) -> Self {
 | 
					 | 
				
			||||||
        Self {
 | 
					 | 
				
			||||||
            path: path.into(),
 | 
					 | 
				
			||||||
            value,
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
impl Display for SetAttribute {
 | 
					impl Display for SetAttribute {
 | 
				
			||||||
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 | 
					    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 | 
				
			||||||
        write!(
 | 
					        write!(
 | 
				
			||||||
| 
						 | 
					@ -963,16 +954,6 @@ pub struct Service {
 | 
				
			||||||
    pub arguments: Vec<String>,
 | 
					    pub arguments: Vec<String>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Service {
 | 
					 | 
				
			||||||
    pub fn spawn(&self) -> Result<(), CommandError> {
 | 
					 | 
				
			||||||
        Client::new().execute(HlwmCommand::Spawn {
 | 
					 | 
				
			||||||
            executable: self.name.clone(),
 | 
					 | 
				
			||||||
            args: self.arguments.clone(),
 | 
					 | 
				
			||||||
        })?;
 | 
					 | 
				
			||||||
        Ok(())
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#[cfg(test)]
 | 
					#[cfg(test)]
 | 
				
			||||||
mod test {
 | 
					mod test {
 | 
				
			||||||
    use pretty_assertions::assert_eq;
 | 
					    use pretty_assertions::assert_eq;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@ use std::{
 | 
				
			||||||
    fmt::Display,
 | 
					    fmt::Display,
 | 
				
			||||||
    num::{ParseFloatError, ParseIntError},
 | 
					    num::{ParseFloatError, ParseIntError},
 | 
				
			||||||
    os::unix::process::ExitStatusExt,
 | 
					    os::unix::process::ExitStatusExt,
 | 
				
			||||||
    process::{self, Child, Stdio},
 | 
					    process::{self, Stdio},
 | 
				
			||||||
    str::FromStr,
 | 
					    str::FromStr,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ impl Client {
 | 
				
			||||||
    /// To run the command and return a handle instead of waiting,
 | 
					    /// To run the command and return a handle instead of waiting,
 | 
				
			||||||
    /// see [Client::spawn]
 | 
					    /// see [Client::spawn]
 | 
				
			||||||
    pub fn execute(&self, command: HlwmCommand) -> Result<process::Output, CommandError> {
 | 
					    pub fn execute(&self, command: HlwmCommand) -> Result<process::Output, CommandError> {
 | 
				
			||||||
        let mut args = command.args();
 | 
					        let args = command.args();
 | 
				
			||||||
        debug!("running command: [{}]", (&args).join(" "),);
 | 
					        debug!("running command: [{}]", (&args).join(" "),);
 | 
				
			||||||
        let output = Self::herbstclient()
 | 
					        let output = Self::herbstclient()
 | 
				
			||||||
            .args(args)
 | 
					            .args(args)
 | 
				
			||||||
| 
						 | 
					@ -115,25 +115,6 @@ impl Client {
 | 
				
			||||||
        Ok(())
 | 
					        Ok(())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn spawn(self, command: HlwmCommand) -> Result<Child, CommandError> {
 | 
					 | 
				
			||||||
        Ok(Self::herbstclient().args(command.args()).spawn()?)
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn set_setting(&self, setting: Setting) -> Result<(), CommandError> {
 | 
					 | 
				
			||||||
        self.execute(HlwmCommand::Set(setting))?;
 | 
					 | 
				
			||||||
        Ok(())
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn get_attr_out(&self, attr: String, out: &mut Attribute) -> Result<(), CommandError> {
 | 
					 | 
				
			||||||
        Ok(*out = Attribute::new(
 | 
					 | 
				
			||||||
            &out.type_string(),
 | 
					 | 
				
			||||||
            &self
 | 
					 | 
				
			||||||
                .query(HlwmCommand::GetAttr(attr))?
 | 
					 | 
				
			||||||
                .first()
 | 
					 | 
				
			||||||
                .ok_or(CommandError::Empty)?,
 | 
					 | 
				
			||||||
        )?)
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn get_attr(&self, attr: String) -> Result<Attribute, CommandError> {
 | 
					    pub fn get_attr(&self, attr: String) -> Result<Attribute, CommandError> {
 | 
				
			||||||
        let attr_type = self
 | 
					        let attr_type = self
 | 
				
			||||||
            .query(HlwmCommand::AttrType(attr.clone()))?
 | 
					            .query(HlwmCommand::AttrType(attr.clone()))?
 | 
				
			||||||
| 
						 | 
					@ -148,11 +129,6 @@ impl Client {
 | 
				
			||||||
        Ok(Attribute::new(&attr_type, &attr_val)?)
 | 
					        Ok(Attribute::new(&attr_type, &attr_val)?)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn set_attr(&self, path: String, new_value: Attribute) -> Result<(), CommandError> {
 | 
					 | 
				
			||||||
        self.execute(HlwmCommand::SetAttr { path, new_value })?;
 | 
					 | 
				
			||||||
        Ok(())
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pub fn get_setting(&self, setting: SettingName) -> Result<Setting, CommandError> {
 | 
					    pub fn get_setting(&self, setting: SettingName) -> Result<Setting, CommandError> {
 | 
				
			||||||
        Ok(Setting::from_str(&String::from_utf8(
 | 
					        Ok(Setting::from_str(&String::from_utf8(
 | 
				
			||||||
            self.execute(HlwmCommand::Get(setting))?.stdout,
 | 
					            self.execute(HlwmCommand::Get(setting))?.stdout,
 | 
				
			||||||
| 
						 | 
					@ -431,7 +407,7 @@ impl FromStr for Align {
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        match align {
 | 
					        match align {
 | 
				
			||||||
            "bottom" | "vertical" | "horiz" | "v" => Ok(Self::Bottom(fraction)),
 | 
					            "bottom" | "vertical" | "vert" | "v" => Ok(Self::Bottom(fraction)),
 | 
				
			||||||
            "left" => Ok(Self::Left(fraction)),
 | 
					            "left" => Ok(Self::Left(fraction)),
 | 
				
			||||||
            "right" | "horizontal" | "horiz" | "h" => Ok(Self::Right(fraction)),
 | 
					            "right" | "horizontal" | "horiz" | "h" => Ok(Self::Right(fraction)),
 | 
				
			||||||
            "top" => Ok(Self::Top(fraction)),
 | 
					            "top" => Ok(Self::Top(fraction)),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,6 +65,7 @@ pub struct TagStatus {
 | 
				
			||||||
    state: TagState,
 | 
					    state: TagState,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[allow(unused)]
 | 
				
			||||||
impl TagStatus {
 | 
					impl TagStatus {
 | 
				
			||||||
    pub fn name(&self) -> &str {
 | 
					    pub fn name(&self) -> &str {
 | 
				
			||||||
        &self.name
 | 
					        &self.name
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue