index : bitwarden-ssh-agent.git

ascending towards madness

author holly sparkles <sparkles@holly.sh> 2023-08-04 10:31:32.0 +00:00:00
committer holly sparkles <sparkles@holly.sh> 2023-08-04 10:31:32.0 +00:00:00
commit
4be75024c640def5d656976356a8c26c2147c836 [patch]
tree
9c9c398c5dc916b22fcf3623dc0a20df5af80de2
parent
88681e0b8afcccc61eb5208b37515c046537eac7
download
4be75024c640def5d656976356a8c26c2147c836.tar.gz

feat: add colour to bitwarden error messages



Diff

 src/bwutil.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bwutil.rs b/src/bwutil.rs
index 0e007e5..0254ae9 100644
--- a/src/bwutil.rs
+++ b/src/bwutil.rs
@@ -1,4 +1,5 @@
use std::process::{Command, Output, Stdio};
use colored::*;
use serde::Deserialize;
use anyhow::{anyhow, Result, Context};

@@ -77,7 +78,7 @@ pub fn exec_folder_search(session: &str, folder_name: &str) -> Result<Vec<Bitwar
			["list", "folders", "--search", &folder_name, "--session", &session].to_vec());
	let result: String = String::from_utf8_lossy(&folders.stdout).to_string();
	if result.is_empty() {
		Err(anyhow!("Could not authenticate."))
		Err(anyhow!("Could not authenticate. This could mean your session has expired.".red()))
	}
	else {
		Ok(serde_json::from_str(&result).with_context(|| "Could not deserialize folder search results.")?)
@@ -90,7 +91,7 @@ pub fn exec_list_folder_items(session: &str, folder_id: &str) -> Result<Vec<Bitw
			["list", "items", "--folderid", &folder_id, "--session", &session].to_vec());
	let result = String::from_utf8_lossy(&items.stdout).to_string();
	if result.is_empty() {
		Err(anyhow!("Could not authenticate."))
		Err(anyhow!("Could not authenticate. This could mean your session has expired.".red()))
	}
	else {
		Ok(serde_json::from_str(&result).with_context(|| "Could not deserialize item search results.")?)