about summary refs log tree commit diff
path: root/corp/russian
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-01-18T15·31+0300
committertazjin <tazjin@tvl.su>2023-01-18T15·44+0000
commit0ed6583edcdaac73f4ed7fb30b09d8fb95c25f9d (patch)
treec14660b8ab95f2bcea5510d00c904c2989c79c79 /corp/russian
parent476e312c06213e53757349a93cc7f855889bc61c (diff)
feat(corp/data-import): let users specify output path r/5692
Change-Id: I61ad021c7a5318b099f3adc8bc6aedef65500974
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7865
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'corp/russian')
-rw-r--r--corp/russian/data-import/src/main.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/corp/russian/data-import/src/main.rs b/corp/russian/data-import/src/main.rs
index 70eb0a56dd28..8a76c3823e27 100644
--- a/corp/russian/data-import/src/main.rs
+++ b/corp/russian/data-import/src/main.rs
@@ -69,17 +69,25 @@ fn main() {
         .filter_level(log::LevelFilter::Info)
         .init();
 
-    let input_path = env::args()
-        .skip(1)
-        .next()
-        .ensure("must specify the input filename as the only argument");
+    let (input_path, output_path) = {
+        let mut args = env::args().collect::<Vec<_>>();
+
+        if args.len() != 3 {
+            bail(format!(
+                "usage: {} <input-file> <output-file>",
+                args.first().map(String::as_str).unwrap_or("data-import")
+            ));
+        }
+
+        (args.remove(1), args.remove(1))
+    };
 
-    info!("reading from {input_path}");
+    info!("reading from {input_path}; writing output to {output_path}");
     let input_file = File::open(input_path).ensure("failed to open input file");
 
     let mut parser = oc_parser::OpenCorporaParser::new(BufReader::new(input_file));
 
-    let conn = Connection::open("out.db").ensure("failed to open DB connection");
+    let conn = Connection::open(output_path).ensure("failed to open DB connection");
 
     db_setup::initial_schema(&conn);