Renamed the dump command to save, added command dump to dump the db to stdout.

This commit is contained in:
Oleksandr Kozachuk
2023-01-03 11:58:48 +01:00
parent 1b96ca3239
commit fd3914dacb
3 changed files with 14 additions and 7 deletions
+9 -3
View File
@@ -303,14 +303,20 @@ impl<'a> LKEval<'a> {
}
};
if output.len() > 0 {
out.e(format!("Passwords dumped to command {} and got following output:", cmd));
out.e(format!("Passwords saved to command {} and got following output:", cmd));
out.o(output);
} else {
out.o(format!("Passwords dumped to command {}", cmd));
out.o(format!("Passwords saved to command {}", cmd));
}
} else if script.trim() == "-" {
let mut vals = (&self.state.borrow().db).values().map(|v| v.clone()).collect::<Vec<PasswordRef>>();
vals.sort_by(|a, b| a.borrow().name.cmp(&b.borrow().name));
for pwd in vals {
out.o(format!("add {}", pwd.borrow().to_string()))
};
} else {
match save_dump(&self.state.borrow().db, &script) {
Ok(()) => out.o(format!("Passwords dumped to {}", script)),
Ok(()) => out.o(format!("Passwords saved to file {}", script)),
Err(e) => out.e(format!("error: failed to dump passswords to {}: {}", script, e.to_string())),
};
}