mirror of
https://github.com/aramperes/nut-rs.git
synced 2025-09-09 13:38:30 -04:00
parent
c56be76906
commit
11f70642dd
6 changed files with 34 additions and 8 deletions
|
@ -15,7 +15,7 @@ pub fn list_devices(config: Config, with_description: bool) -> anyhow::Result<()
|
|||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
logout(conn)
|
||||
}
|
||||
|
||||
pub fn print_variable(config: Config, ups_name: &str, variable: &str) -> anyhow::Result<()> {
|
||||
|
@ -24,7 +24,7 @@ pub fn print_variable(config: Config, ups_name: &str, variable: &str) -> anyhow:
|
|||
let variable = conn.get_var(ups_name, variable)?;
|
||||
println!("{}", variable.value());
|
||||
|
||||
Ok(())
|
||||
logout(conn)
|
||||
}
|
||||
|
||||
pub fn list_variables(config: Config, ups_name: &str) -> anyhow::Result<()> {
|
||||
|
@ -34,7 +34,7 @@ pub fn list_variables(config: Config, ups_name: &str) -> anyhow::Result<()> {
|
|||
println!("{}", var);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
logout(conn)
|
||||
}
|
||||
|
||||
pub fn list_clients(config: Config, ups_name: &str) -> anyhow::Result<()> {
|
||||
|
@ -44,9 +44,13 @@ pub fn list_clients(config: Config, ups_name: &str) -> anyhow::Result<()> {
|
|||
println!("{}", client_ip);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
logout(conn)
|
||||
}
|
||||
|
||||
fn connect(config: Config) -> anyhow::Result<Connection> {
|
||||
Connection::new(&config).with_context(|| format!("Failed to connect to upsd: {:?}", &config))
|
||||
}
|
||||
|
||||
fn logout(conn: Connection) -> anyhow::Result<()> {
|
||||
conn.close().with_context(|| "Failed to close gracefully")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue