From 582f56e915a7c88eb0372496e298c9944f5832ae Mon Sep 17 00:00:00 2001 From: Patrick Jackson Date: Tue, 26 Mar 2024 17:00:28 -0600 Subject: feat: add `save_session` config item and `--save-session` cli option (#370) * fix: sessions should save when exiting * feat: improve save sessions * feat: do not allow saving the temp session name * feat: allow creating a session without interactive use * feat: add `save_session` config and `--save-session` option --------- Co-authored-by: sigoden --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 589676e..502f6d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,9 @@ fn main() -> Result<()> { if let Some(wrap) = &cli.wrap { config.write().set_wrap(wrap)?; } + if cli.save_session { + config.write().save_session = true; + } if cli.light_theme { config.write().light_theme = true; } @@ -111,9 +114,6 @@ fn start_directive( no_stream: bool, code_mode: bool, ) -> Result<()> { - if let Some(session) = &config.read().session { - session.guard_save()?; - } let input = Input::new( text, include.unwrap_or_default(), @@ -141,7 +141,9 @@ fn start_directive( let abort = create_abort_signal(); render_stream(&input, client.as_ref(), config, abort)? }; + // Save the message/session config.write().save_message(input, &output)?; + config.write().end_session(false)?; Ok(()) } -- cgit v1.2.3