worf-warden, do not show ui on rbw error
This commit is contained in:
parent
e39b006f71
commit
93fe365975
1 changed files with 23 additions and 41 deletions
|
@ -24,10 +24,8 @@ fn split_at_tab(input: &str) -> Option<(&str, &str)> {
|
|||
}
|
||||
|
||||
impl PasswordProvider {
|
||||
fn new(config: &Config) -> Self {
|
||||
let output = rbw("list", Some(vec!["--fields", "id,name"]));
|
||||
let items = match output {
|
||||
Ok(output) => {
|
||||
fn new(config: &Config) -> Result<Self, String> {
|
||||
let output = rbw("list", Some(vec!["--fields", "id,name"]))?;
|
||||
let mut items = output
|
||||
.lines()
|
||||
.filter_map(|s| split_at_tab(s))
|
||||
|
@ -52,23 +50,8 @@ impl PasswordProvider {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
gui::apply_sort(&mut items, &config.sort_order());
|
||||
items
|
||||
}
|
||||
Err(error) => {
|
||||
let item = MenuItem::new(
|
||||
format!("Error from rbw: {error}"),
|
||||
None,
|
||||
None,
|
||||
vec![].into_iter().collect(),
|
||||
None,
|
||||
0.0,
|
||||
None,
|
||||
);
|
||||
vec![item]
|
||||
}
|
||||
};
|
||||
|
||||
Self { items }
|
||||
Ok(Self { items })
|
||||
}
|
||||
|
||||
fn sub_provider(ids: Vec<String>) -> Result<Self, String> {
|
||||
|
@ -376,7 +359,6 @@ fn main() -> Result<(), String> {
|
|||
spawn_fork("ydotoold", None).expect("failed to spawn ydotoold");
|
||||
|
||||
// todo eventually use a propper rust client for this, for now rbw is good enough
|
||||
let provider = PasswordProvider::new(&config);
|
||||
|
||||
let provider = PasswordProvider::new(&config)?;
|
||||
show(config, provider)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue