-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make cli handle multiple whitespaces #1388
Conversation
@@ -90,7 +90,8 @@ pub async fn exec_from_repl(ctx: &mut Context, print_options: &PrintOptions) { | |||
match rl.readline("❯ ") { | |||
Ok(line) if line.starts_with('\\') => { | |||
rl.add_history_entry(line.trim_end()); | |||
if let Ok(cmd) = &line[1..].parse::<Command>() { | |||
let command = line.split_whitespace().collect::<Vec<_>>().join(" "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried the trim method? https://doc.rust-lang.org/stable/std/string/struct.String.html#method.trim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I'd like to fix here is not only leading and trailing whitespaces.
Currently, the behavior is like
DataFusion CLI v5.1.0
❯ \quiet true
'\quiet true' is not a valid command
❯ \pset format csv
'\pset format csv' is not a valid command
❯ \pset format csv
Execution error: csv is not a valid format type [possible values: csv, tsv, table, json, ndjson]
Without normalizing whitespaces before parsing commands, every command need to do trim like here.
https://github.com/apache/arrow-datafusion/blob/42f8ab1e44510cea73f9eb2300d28f2fa92ac55a/datafusion-cli/src/functions.rs#L159
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i see, thanks for the context.
eventually, we will need to write a proper lexer and parser for pgcli commands :P |
Thanks @capkurmagati -- I think this is a small enough fix we can iterate on it if @jimexist has some suggestions as well |
Which issue does this PR close?
The cli cannot handle whitespace like
The PR fixes this issue by removing the consecutive whitespaces.
Closes #.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?