🐛 Fixes bw using wrong command to get items
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user