From cc601fecdec5be8adbd10966404862589482b74d Mon Sep 17 00:00:00 2001 From: Karcsesz Date: Wed, 14 Feb 2024 21:14:43 +0100 Subject: [PATCH] Advertise the --save flag more prominently --- src/args_parser.rs | 4 ++-- src/editor/commands.rs | 2 +- src/editor/commands/editor.rs | 3 +++ src/editor/commands/fetch.rs | 1 + src/editor/commands/init.rs | 2 +- src/main.rs | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/args_parser.rs b/src/args_parser.rs index 1e89e04..2218ce6 100644 --- a/src/args_parser.rs +++ b/src/args_parser.rs @@ -107,8 +107,8 @@ pub enum Command { Init { /// Force creating a new database even if one exists already. WILL DELETE DATA! #[arg(long, short = 'f')] - force: bool - } + force: bool, + }, } #[derive(ValueEnum, Debug, Eq, PartialEq, Copy, Clone)] diff --git a/src/editor/commands.rs b/src/editor/commands.rs index 1a82c5f..288bc74 100644 --- a/src/editor/commands.rs +++ b/src/editor/commands.rs @@ -1,4 +1,4 @@ pub mod editor; pub mod fetch; -pub mod query; pub mod init; +pub mod query; diff --git a/src/editor/commands/editor.rs b/src/editor/commands/editor.rs index 431c5c4..f31ed9a 100644 --- a/src/editor/commands/editor.rs +++ b/src/editor/commands/editor.rs @@ -2,6 +2,7 @@ use crate::args_parser::SaveSettings; use crate::editor::open_in_editor::open_resource_in_editor; use crate::schema::lookup_handler::LookupHandler; use std::path::PathBuf; +use tracing::info; pub fn editor(database_path: PathBuf, save_settings: SaveSettings, resource: String) { let resources = LookupHandler::load(&database_path).unwrap(); @@ -13,5 +14,7 @@ pub fn editor(database_path: PathBuf, save_settings: SaveSettings, resource: Str let mut resources = resources.into_inner(); resources.0[index] = resource; resources.save(database_path).unwrap(); + } else { + info!("To save edits, run this command with the -s flag") } } diff --git a/src/editor/commands/fetch.rs b/src/editor/commands/fetch.rs index 79083d0..07695f1 100644 --- a/src/editor/commands/fetch.rs +++ b/src/editor/commands/fetch.rs @@ -64,5 +64,6 @@ pub fn fetch( for resource in new_resources { println!("{resource}") } + info!("To save changes, rerun this command with the -s flag set") } } diff --git a/src/editor/commands/init.rs b/src/editor/commands/init.rs index 4305fd7..0ec7461 100644 --- a/src/editor/commands/init.rs +++ b/src/editor/commands/init.rs @@ -15,4 +15,4 @@ pub fn init(database_path: PathBuf, force: bool) { let mut file = std::fs::File::create(database_path).unwrap(); file.write_all(b"[]").unwrap(); info!("Initialised empty database"); -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 9c01e9a..e54fc2b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ use crate::args_parser::Command; use crate::editor::commands::editor::editor; +use crate::editor::commands::init::init; use crate::editor::try_reload_server::reload; use clap::Parser; use editor::commands::fetch::fetch; use editor::commands::query::query; use tracing_subscriber::util::SubscriberInitExt; -use crate::editor::commands::init::init; mod args_parser; #[cfg(feature = "editor")]