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

feat: add output null and time #101

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub enum OutputFormat {
Table,
CSV,
TSV,
Time,
Null,
}

impl Settings {
Expand All @@ -64,6 +66,8 @@ impl Settings {
"table" => OutputFormat::Table,
"csv" => OutputFormat::CSV,
"tsv" => OutputFormat::TSV,
"null" => OutputFormat::Null,
"time" => OutputFormat::Time,
_ => return Err(anyhow!("Unknown output format: {}", cmd_value)),
}
}
Expand Down
4 changes: 4 additions & 0 deletions cli/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ impl<'a> ChunkDisplay for FormatDisplay<'a> {
wtr.write_record(record)?;
}
}
OutputFormat::Time => {
println!("{:.3}", self._start.elapsed().as_secs_f64());
}
OutputFormat::Null => {}
}
Ok(())
}
Expand Down
7 changes: 7 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ struct Args {

#[clap(long, help = "Show progress for data loading in stderr")]
progress: bool,

#[clap(long, help = "Only show execution time without results")]
time: bool,
}

/// Parse a single key-value pair
Expand Down Expand Up @@ -249,6 +252,10 @@ pub async fn main() -> Result<()> {
config.settings.output_format = OutputFormat::TSV;
}

if args.time {
config.settings.output_format = OutputFormat::Time;
}

let mut session = session::Session::try_new(dsn, config.settings, is_repl).await?;

if is_repl {
Expand Down