Add ld command, like ls but sort by date. Fix quit command in scripts, output passwords with spaces when no prefix given (align output by name, somewhat).

This commit is contained in:
Oleksandr Kozachuk
2022-12-24 13:53:53 +01:00
parent f0ce3b4d96
commit a69fceb126
6 changed files with 23 additions and 14 deletions
+4 -3
View File
@@ -57,6 +57,7 @@ pub enum LKErr<'a> {
pub enum Command<'a> {
Add(PasswordRef),
Ls(String),
Ld(String),
Mv(Name, Name),
Rm(Name),
Enc(Name),
@@ -259,14 +260,14 @@ impl fmt::Display for Radix {
}
}
pub fn init() -> LKRead {
pub fn init() -> Option<LKRead> {
let lk = Rc::new(RefCell::new(LK::new()));
match std::fs::read_to_string(INIT_FILE.to_str().unwrap()) {
Ok(script) => match command_parser::script(&script) {
Ok(cmd_list) => {
for cmd in cmd_list {
LKEval::new(cmd, lk.clone(), prompt_password).eval().print();
if !LKEval::new(cmd, lk.clone(), prompt_password).eval().print() { return None; }
}
}
Err(err) => {
@@ -286,7 +287,7 @@ pub fn init() -> LKRead {
.print();
}
}
LKRead::new(Editor::<()>::new().unwrap(), PROMPT_SETTING.to_string(), lk.clone())
Some(LKRead::new(Editor::<()>::new().unwrap(), PROMPT_SETTING.to_string(), lk.clone()))
}
#[cfg(test)]