From 791606ad1b9455834172d43a221d5f79baaa1a14 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Tue, 17 Sep 2024 15:55:54 +0000 Subject: [PATCH] edit begin --- src/main.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 12845f0..46c346d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,20 +27,24 @@ enum Commands { /// Lists all ids stored in db List, + /// Show content of item + Show { + #[arg(value_name="item_id")] + id: String + }, + /// Adds new item with unique id to the db Add { #[arg(value_name="item_id")] id: String }, - /// Show content of item - Show { + /// Edit item content + Edit { #[arg(value_name="item_id")] id: String } - // TODO: edit - } enum PROMPT { @@ -130,6 +134,11 @@ fn add(id: &String) -> io::Result<()> { Ok(()) } +fn edit(id: &String) -> io::Result<()> { + // TODO: implement + Ok(()) +} + fn show(id: &String) -> io::Result<()> { let passphrase = login()?; let mut st = Storage::from_db(passphrase)?; @@ -151,14 +160,17 @@ fn run_command() -> io::Result<()> { Some(Commands::Init) => { init()?; } - Some(Commands::Add{ id }) => { - add(id)?; + Some(Commands::List) => { + list()?; } - Some(Commands::Show{ id }) => { + Some(Commands::Show { id }) => { show(id)?; } - Some(Commands::List) => { - list()?; + Some(Commands::Add { id }) => { + add(id)?; + } + Some(Commands::Edit { id }) => { + edit(id)? } None => { if !Storage::is_inited() {