-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from developmentseed/cql2textout
Add round trip back to CQL2 Text, Start output work for SQL, Add Commands
- Loading branch information
Showing
6 changed files
with
349 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use atty::Stream; | ||
use cql2::parse; | ||
use std::env; | ||
use std::io; | ||
use std::process::ExitCode; | ||
|
||
fn main() -> ExitCode { | ||
let args: Vec<String> = env::args().collect(); | ||
let mut buffer = String::new(); | ||
if args.len() >= 2 { | ||
buffer = args[1].to_string(); | ||
} else if atty::isnt(Stream::Stdin) { | ||
io::stdin().read_line(&mut buffer).unwrap(); | ||
} else { | ||
println!("Enter CQL2 as Text or JSON, then hit return"); | ||
io::stdin().read_line(&mut buffer).unwrap(); | ||
} | ||
let parsed = parse(&buffer); | ||
if args.len() == 3 && args[2] == "pretty" { | ||
println!("{}", parsed.as_json_pretty()); | ||
} else { | ||
println!("{}", parsed.as_json()); | ||
} | ||
|
||
if parsed.validate() { | ||
return 0.into(); | ||
} | ||
1.into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use atty::Stream; | ||
use cql2::parse; | ||
use std::env; | ||
use std::io; | ||
use std::process::ExitCode; | ||
|
||
fn main() -> ExitCode { | ||
let args: Vec<String> = env::args().collect(); | ||
let mut buffer = String::new(); | ||
if args.len() == 2 { | ||
buffer = args[1].to_string(); | ||
} else if atty::isnt(Stream::Stdin) { | ||
io::stdin().read_line(&mut buffer).unwrap(); | ||
} else { | ||
println!("Enter CQL2 as Text or JSON, then hit return"); | ||
io::stdin().read_line(&mut buffer).unwrap(); | ||
} | ||
let parsed = parse(&buffer); | ||
println!("{}", parsed.as_cql2_text()); | ||
if parsed.validate() { | ||
return 0.into(); | ||
} | ||
1.into() | ||
} |
Oops, something went wrong.