🐛 Fixes bw using wrong command to get items

This commit is contained in:
2026-07-19 16:34:42 +02:00
parent 8d4b007c51
commit bfc24d312d
2 changed files with 22 additions and 22 deletions
+6 -14
View File
@@ -1,6 +1,6 @@
use crate::sh;
use serde::Deserialize;
use std::io::{Error, ErrorKind};
use std::io::{Error, ErrorKind, Write, stdin, stdout};
const EXECUTABLE: &str = "bw";
@@ -42,7 +42,7 @@ pub struct ItemField {
pub struct Login {
pub uris: Vec<LoginUri>,
pub username: String,
pub password: String,
pub password: Option<String>,
pub totp: Option<String>,
#[serde(rename = "passwordRevisionDate")]
pub password_revision_date: Option<String>,
@@ -83,7 +83,7 @@ pub struct Fido2Credential {
pub creation_date: String,
}
pub fn check_bw() -> Result<String, Error> {
pub fn check_bw() -> Result<(), Error> {
let which = sh::sh(format!("which {}", EXECUTABLE));
if which.is_empty() {
return Err(Error::new(
@@ -92,19 +92,11 @@ pub fn check_bw() -> Result<String, Error> {
));
}
let session = sh::sh(format!("{} unlock", EXECUTABLE));
if session.is_empty() {
return Err(Error::new(
ErrorKind::Other,
format!("{} couldn't unlock", EXECUTABLE),
));
}
Ok(session)
Ok(())
}
pub fn get_items(session: String) -> Result<Vec<Item>, Error> {
let items_raw = sh::sh(format!("BW_SESSION={} {} list --raw", session, EXECUTABLE));
pub fn get_items() -> Result<Vec<Item>, Error> {
let items_raw = sh::sh(format!("{} list items --raw", EXECUTABLE));
match serde_json::from_str(items_raw.as_str()) {
Ok(val) => Ok(val),
Err(e) => Err(Error::new(