Skip to content
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

#1268: allow datafusion-cli to toggle quiet flag within CLI #1330

Merged
merged 2 commits into from
Nov 21, 2021

Conversation

jgoday
Copy link
Contributor

@jgoday jgoday commented Nov 18, 2021

Which issue does this PR close?

Closes #1268.

Rationale for this change

Allow to toggle quiet mode inside de datafusion-cli.

What changes are included in this PR?

Adds a datafusion-cli command (QuietMode bool) to change the print_options quiet mode in runtime.

Are there any user-facing changes?

A new command is introduced into the datafusion-cli repl.

Updated docs/source/user-guide/cli.md

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Nov 18, 2021
@jgoday jgoday force-pushed the feature/cli_toggle_quiet_mode branch from 6ee2a31 to 08b77c3 Compare November 18, 2021 21:18
@liukun4515
Copy link
Contributor

@jgoday you need address the conflicts.

@@ -117,6 +121,7 @@ impl FromStr for Command {
("d", None) => Self::ListTables,
("d", Some(name)) => Self::DescribeTable(name.into()),
("?", None) => Self::Help,
("quiet", Some(b)) => Self::QuietMode(b == "true" || b == "t"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the doc, we just accept true/false, i think this code is inconsistent with the doc.
Maybe we should consider the lower/upper case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, in psql it's common to have on|off flags (case insensitive), should we do the same ?

\x [on|off|auto]       toggle expanded output (currently off)

@jgoday jgoday force-pushed the feature/cli_toggle_quiet_mode branch from 08b77c3 to be98286 Compare November 19, 2021 14:59
@jgoday
Copy link
Contributor Author

jgoday commented Nov 19, 2021

@jgoday you need address the conflicts.

Ok, rebased to master to avoid conflicts

loop {
match rl.readline("❯ ") {
Ok(line) if line.starts_with('\\') => {
rl.add_history_entry(line.trim_end());
if let Ok(cmd) = &line[1..].parse::<Command>() {
match cmd {
Command::Quit => break,
Command::QuietMode(quiet) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why not move the execution to the command file? quit should be the only exception here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair question, but I did not dare to change the Command::execute signature (to make print_options mutable).
What do you think about that ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it's used outside this repo nor any downstream code so you should feel free to change it as you see fit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then, changed to delegate the mutation to command

Copy link
Member

@jimexist jimexist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jimexist jimexist merged commit e3a682d into apache:master Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow datafusion-cli to toggle quiet flag within CLI
3 participants