Skip to content

Commit

Permalink
feat: add multi line config (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
sundy-li authored May 5, 2023
1 parent 26b4513 commit ef94fdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -153,6 +157,7 @@ impl Default for Settings {
show_progress: false,
show_stats: false,
time: false,
multi_line: true,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions cli/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ef94fdd

Please sign in to comment.