From c86f717e7ff4013823ecb4a814ea5e8312fea188 Mon Sep 17 00:00:00 2001 From: Adeoye Adefemi Date: Mon, 28 Aug 2023 07:02:42 +0100 Subject: [PATCH] chore: refactoring --- .vscode/settings.json | 9 ++++++++- Cargo.lock | 40 ++++++++++++++++++++++++++++++++++++++++ src/commands/store.rs | 5 +++-- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e807669..fc97c31 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,10 @@ { - "cSpell.words": ["sqlx"] + "cSpell.words": [ + "sqlx" + ], + "workbench.colorCustomizations": { + "activityBar.background": "#462511", + "titleBar.activeBackground": "#613417", + "titleBar.activeForeground": "#FDFAF8" + } } diff --git a/Cargo.lock b/Cargo.lock index 227806f..2a08b84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -643,6 +643,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -1371,6 +1392,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_str_bytes" version = "6.5.1" @@ -1633,6 +1660,17 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall 0.2.16", + "thiserror", +] + [[package]] name = "regex" version = "1.9.4" @@ -2359,8 +2397,10 @@ dependencies = [ "clap 4.4.0", "console", "dialoguer", + "dirs", "include_dir", "indicatif", + "lazy_static", "lettre", "serde", "sqlx", diff --git a/src/commands/store.rs b/src/commands/store.rs index c2a1fda..1518381 100644 --- a/src/commands/store.rs +++ b/src/commands/store.rs @@ -1,7 +1,6 @@ -use crate::database::StoreModel; +use crate::{database::StoreModel, style::PrintColoredText}; use clap::{Args, Subcommand}; use serde::{Deserialize, Serialize}; -// let id = Uuid::new_v4(); #[derive(Args, Debug, Serialize)] pub struct StoreCommands { @@ -41,6 +40,8 @@ impl StoreCommands { /*store the key value pair in the database after checking that the key does not exist, if the key exist prompt use to overwrite */ async fn add(key: &str, value: &str) { StoreModel::new(key, value).save().await.unwrap(); + let message = format!("{key} successfully stored"); + PrintColoredText::success(&message); } /* accept a key and update the value of the key */ fn set(key: &str, value: &str) {