🚧 Adds rbw item struct
Signed-off-by: Ash Svitan <selfsigned-ash@proton.me>
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
use crate::sh;
|
||||
use serde::Deserialize;
|
||||
use std::io::{Error, ErrorKind};
|
||||
|
||||
const EXECUTABLE: &str = "rbw";
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Item {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub user: String,
|
||||
pub uris: Vec<String>,
|
||||
#[serde(rename = "type")]
|
||||
pub type_: String,
|
||||
}
|
||||
|
||||
pub fn check_rbw() -> Result<(), Error> {
|
||||
let which = sh::sh(format!("which {}", EXECUTABLE));
|
||||
if which.is_empty() {
|
||||
return Err(Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("{} is not installed", EXECUTABLE),
|
||||
));
|
||||
}
|
||||
|
||||
let unlocked = sh::sh(format!("{} unlocked", EXECUTABLE));
|
||||
if !unlocked.is_empty() {
|
||||
return Err(Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("{} database not unlocked", EXECUTABLE),
|
||||
));
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
Reference in New Issue
Block a user