This is an automated email from the ASF dual-hosted git repository.
jiayuliu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new eaacc70 quiet mode to contain option bool (#1345)
eaacc70 is described below
commit eaacc705f6678bdf4e5076386a245a0f045a2775
Author: Jiayu Liu <[email protected]>
AuthorDate: Mon Nov 22 09:59:29 2021 +0800
quiet mode to contain option bool (#1345)
---
datafusion-cli/src/command.rs | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/datafusion-cli/src/command.rs b/datafusion-cli/src/command.rs
index 39cd5e9..0b7dbe4 100644
--- a/datafusion-cli/src/command.rs
+++ b/datafusion-cli/src/command.rs
@@ -37,7 +37,7 @@ pub enum Command {
DescribeTable(String),
ListFunctions,
SearchFunctions(String),
- QuietMode(bool),
+ QuietMode(Option<bool>),
}
impl Command {
@@ -66,7 +66,18 @@ impl Command {
.map_err(|e| DataFusionError::Execution(e.to_string()))
}
Self::QuietMode(quiet) => {
- print_options.quiet = *quiet;
+ if let Some(quiet) = quiet {
+ print_options.quiet = *quiet;
+ println!(
+ "Quiet mode set to {}",
+ if print_options.quiet { "true" } else { "false" }
+ );
+ } else {
+ println!(
+ "Quiet mode is {}",
+ if print_options.quiet { "true" } else { "false" }
+ );
+ }
Ok(())
}
Self::Quit => Err(DataFusionError::Execution(
@@ -94,7 +105,7 @@ impl Command {
Self::Help => ("\\?", "help"),
Self::ListFunctions => ("\\h", "function list"),
Self::SearchFunctions(_) => ("\\h function", "search function"),
- Self::QuietMode(_) => ("\\quiet", "set quiet mode"),
+ Self::QuietMode(_) => ("\\quiet (true|false)?", "print or set
quiet mode"),
}
}
}
@@ -106,7 +117,7 @@ const ALL_COMMANDS: [Command; 7] = [
Command::Help,
Command::ListFunctions,
Command::SearchFunctions(String::new()),
- Command::QuietMode(false),
+ Command::QuietMode(None),
];
fn all_commands_info() -> RecordBatch {
@@ -144,7 +155,13 @@ impl FromStr for Command {
("?", None) => Self::Help,
("h", None) => Self::ListFunctions,
("h", Some(function)) => Self::SearchFunctions(function.into()),
- ("quiet", Some(b)) => Self::QuietMode(b == "true"),
+ ("quiet", Some("true" | "t" | "yes" | "y" | "on")) => {
+ Self::QuietMode(Some(true))
+ }
+ ("quiet", Some("false" | "f" | "no" | "n" | "off")) => {
+ Self::QuietMode(Some(false))
+ }
+ ("quiet", None) => Self::QuietMode(None),
_ => return Err(()),
})
}