Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
172 changes: 1 addition & 171 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use clap::{ArgAction, Parser, ValueEnum};
use cql2::{Expr, ToSqlAst, Validator};
use cql2::{Expr, ToElasticsearch, ToSqlAst, Validator};
use std::io::Read;

/// The CQL2 command-line interface.
Expand Down Expand Up @@ -69,6 +69,12 @@ enum OutputFormat {

/// SQL
Sql,

/// Elasticsearch DSL, pretty-printed
ElasticsearchPretty,

/// Elasticsearch DSL, compact
Elasticsearch,
}

impl Cli {
Expand Down Expand Up @@ -173,6 +179,14 @@ impl Cli {
let sql_ast = expr.to_sql_ast()?;
println!("{}", sql_ast);
}
OutputFormat::ElasticsearchPretty => {
let dsl = expr.to_elasticsearch()?;
serde_json::to_writer_pretty(std::io::stdout(), &dsl)?;
}
OutputFormat::Elasticsearch => {
let dsl = expr.to_elasticsearch()?;
serde_json::to_writer(std::io::stdout(), &dsl)?;
}
}
println!();
Ok(())
Expand Down
Loading