aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTeddy Wing2022-03-13 13:35:36 +0100
committerTeddy Wing2022-03-13 13:35:36 +0100
commitdeaca6ce619226614b9e1b770590515a7b80d9a0 (patch)
tree31bc3904a5147b063c848567666936e470e4cb74 /src/main.rs
parent1b7be85a2f9c62e809b2081c0dd7219d76740175 (diff)
downloadyaqlite-deaca6ce619226614b9e1b770590515a7b80d9a0.tar.bz2
main(): Accept input YAML from standard input
Either with a "-" argument or no file argument.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 5e06bb2..77092fa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,9 +41,22 @@ fn main() {
table_name,
input_file,
} => {
+ let input_file = match &input_file {
+ Some(f) => f,
+ None => "-",
+ };
+
let mut dbconn = rusqlite::Connection::open(database).unwrap();
- let text_data = std::fs::read_to_string(input_file.unwrap()).unwrap();
+ let mut text_data;
+ if input_file == "-" {
+ use std::io::Read;
+
+ text_data = String::new();
+ std::io::stdin().read_to_string(&mut text_data).unwrap();
+ } else {
+ text_data = std::fs::read_to_string(input_file).unwrap();
+ }
let mut yaml_data = yaml::YamlLoader::load_from_str(&text_data).unwrap();