mirror of
https://github.com/aramperes/nut-rs.git
synced 2025-09-09 05:28:31 -04:00
Simplify errors
This commit is contained in:
parent
c935d88496
commit
96fbfeaeab
8 changed files with 109 additions and 135 deletions
|
@ -8,9 +8,9 @@ use core::convert::TryInto;
|
|||
use anyhow::Context;
|
||||
use clap::{App, Arg};
|
||||
|
||||
use crate::parser::UpsdName;
|
||||
use rups::UpsdName;
|
||||
|
||||
mod cmd;
|
||||
mod parser;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let args = App::new(clap::crate_name!())
|
||||
|
@ -72,7 +72,7 @@ fn main() -> anyhow::Result<()> {
|
|||
)
|
||||
.get_matches();
|
||||
|
||||
let server: parser::UpsdName = args.value_of("upsd-server").map_or_else(
|
||||
let server: UpsdName = args.value_of("upsd-server").map_or_else(
|
||||
|| Ok(UpsdName::default()),
|
||||
|s| s.try_into().with_context(|| "Invalid upsd server name"),
|
||||
)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue