Exit with 1 status code when there is no passwords to list

This commit is contained in:
TheAwiteb 2023-12-24 20:22:28 +03:00
parent c62cfa611c
commit ba71088679
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34

View file

@ -51,7 +51,9 @@ pub struct List {
impl RunCommand for List { impl RunCommand for List {
fn run(&self, password_manager: Passwords) -> PassrsResult<()> { fn run(&self, password_manager: Passwords) -> PassrsResult<()> {
if password_manager.passwords.is_empty() { if password_manager.passwords.is_empty() {
println!("Looks like there is no passwords to list") Err(PassrsError::Other(
"Looks like there is no passwords to list".to_owned(),
))
} else { } else {
if self.get.is_some() && self.search.is_some() { if self.get.is_some() && self.search.is_some() {
return Err(PassrsError::ArgsConflict( return Err(PassrsError::ArgsConflict(
@ -132,7 +134,7 @@ impl RunCommand for List {
table.add_row(row); table.add_row(row);
} }
println!("{table}"); println!("{table}");
}
Ok(()) Ok(())
} }
}
} }