From ef94fdd2606f9c9273d7c49177a5af43ab2baf36 Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Thu, 4 May 2023 23:49:26 -0700 Subject: [PATCH] feat: add multi line config (#108) --- cli/src/config.rs | 5 +++++ cli/src/session.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cli/src/config.rs b/cli/src/config.rs index b59791bf1..8dbb38586 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -59,6 +59,9 @@ pub struct Settings { /// Show time elapsed when executing queries. /// only works with output format `null`. pub time: bool, + + /// Multi line mode, default is true. + pub multi_line: bool, } #[derive(ValueEnum, Clone, Debug, PartialEq, Deserialize)] @@ -105,6 +108,7 @@ impl Settings { } } "time" => self.time = cmd_value.parse()?, + "multi_line" => self.multi_line = cmd_value.parse()?, _ => return Err(anyhow!("Unknown command: {}", cmd_name)), } Ok(()) @@ -153,6 +157,7 @@ impl Default for Settings { show_progress: false, show_stats: false, time: false, + multi_line: true, } } } diff --git a/cli/src/session.rs b/cli/src/session.rs index 62a286d92..ecb35c195 100644 --- a/cli/src/session.rs +++ b/cli/src/session.rs @@ -184,6 +184,10 @@ impl Session { return vec![line.to_owned()]; } + if !self.settings.multi_line { + return vec![line.to_owned()]; + } + self.query.push(' '); self.query.push_str(line);