Skip to content
Snippets Groups Projects
Commit 9619b1c3 authored by Вартан Бабаян's avatar Вартан Бабаян :dart:
Browse files

fix: treating backslashed command in picodata admin/connect

parent 57451ee6
No related branches found
No related tags found
1 merge request!1390add EOF as second delimiter along with ;
......@@ -254,12 +254,12 @@ fn admin_repl(args: args::Admin) -> Result<(), ReplError> {
const HELP_MESSAGE: &'static str = "
Available backslash commands:
\\e; Open the editor specified by the EDITOR environment variable
\\help; Show this screen
\\sql; Switch console language to SQL (default)
\\lua; Switch console language to Lua (deprecated)
\\set delimiter shiny-delimiter; Set console delimiter to 'shiny-delimiter'
\\set delimiter default; Reset console delimiter to default (;)
\\e Open the editor specified by the EDITOR environment variable
\\help Show this screen
\\sql Switch console language to SQL (default)
\\lua Switch console language to Lua (deprecated)
\\set delimiter shiny-delimiter Set console delimiter to 'shiny-delimiter'
\\set delimiter default Reset console delimiter to default (;)
Available hotkeys:
Enter Submit the request
......
......@@ -217,10 +217,10 @@ fn sql_repl(args: args::Connect) -> Result<(), ReplError> {
const HELP_MESSAGE: &'static str = "
Available backslash commands:
\\e; Open the editor specified by the EDITOR environment variable
\\help; Show this screen
\\set delimiter shiny-delimiter; Set console delimiter to 'shiny-delimiter'
\\set delimiter default; Reset console delimiter to default (;)
\\e Open the editor specified by the EDITOR environment variable
\\help Show this screen
\\set delimiter shiny-delimiter Set console delimiter to 'shiny-delimiter'
\\set delimiter default Reset console delimiter to default (;)
Available hotkeys:
Enter Submit the request
......
......@@ -210,18 +210,30 @@ impl<T: Helper> Console<T> {
match readline {
Ok(line) => {
self.uncompleted_statement += &line;
if let Some(ref delimiter) = self.delimiter {
while let Some((separated_part, tail)) =
self.uncompleted_statement.split_once(delimiter)
{
self.separated_statements.push_back(separated_part.into());
self.uncompleted_statement = tail.into();
if line.starts_with(Self::SPECIAL_COMMAND_PREFIX) {
let processed = self.handle_special_command(&line)?;
match processed {
ControlFlow::Continue(_) => continue,
ControlFlow::Break(command) => {
return self.update_history(command)
}
}
}
else {
self.uncompleted_statement += &line;
if let Some(ref delimiter) = self.delimiter {
while let Some((separated_part, tail)) =
self.uncompleted_statement.split_once(delimiter)
{
self.separated_statements.push_back(separated_part.into());
self.uncompleted_statement = tail.into();
}
} else {
self.separated_statements
.push_back(std::mem::take(&mut self.uncompleted_statement));
}
} else {
self.separated_statements
.push_back(std::mem::take(&mut self.uncompleted_statement));
}
}
Err(ReadlineError::Interrupted) => {
......@@ -266,7 +278,7 @@ impl<T: Helper> Console<T> {
/// Prints information about connection and help hint
pub fn greet(&self, connection_info: &str) {
self.write(connection_info);
self.write("type '\\help;' for interactive help");
self.write("type '\\help' for interactive help");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment