codegen-rust now takes the input file from a CLI parameter

This commit is contained in:
Savanni D'Gerinel 2024-03-10 11:48:55 -04:00
parent 4cfc6425e1
commit 1881fb99ce
3 changed files with 11 additions and 16 deletions

17
Cargo.lock generated
View File

@ -2713,9 +2713,6 @@ dependencies = [
[[package]]
name = "kifu-l10n"
version = "0.1.0"
dependencies = [
"messages-codegen",
]
[[package]]
name = "kv-log-macro"
@ -2732,12 +2729,15 @@ version = "0.1.0"
dependencies = [
"chrono",
"chrono-tz",
"convert_case",
"fixed_decimal",
"fluent",
"fluent-ergonomics",
"icu",
"icu_locid",
"icu_provider",
"serde 1.0.193",
"serde_yaml",
"sys-locale",
"unic-langid",
]
@ -2917,17 +2917,6 @@ dependencies = [
"tokio",
]
[[package]]
name = "messages-codegen"
version = "0.1.0"
dependencies = [
"convert_case",
"quote",
"serde 1.0.193",
"serde_yaml",
"syn 2.0.48",
]
[[package]]
name = "mime"
version = "0.2.6"

View File

@ -8,12 +8,15 @@ edition = "2021"
[dependencies]
chrono = { version = "0.4" }
chrono-tz = { version = "0.8" }
convert_case = { version = "0.6" }
fixed_decimal = { version = "0.5.5", features = [ "ryu" ] }
fluent = { version = "0.16" }
fluent-ergonomics = { path = "../fluent-ergonomics" }
icu = { version = "1" }
icu_locid = { version = "1" }
icu_provider = { version = "1" }
serde = { version = "1" }
serde_yaml = { version = "0.9" }
sys-locale = { version = "0.3" }
unic-langid = { version = "*" }

View File

@ -1,7 +1,7 @@
use convert_case::{Case, Casing};
use serde::Deserialize;
use serde_yaml;
use std::{collections::HashMap, fmt, fs::File};
use std::{collections::HashMap, fmt, fs::File, env};
#[derive(Debug, Clone, Deserialize)]
struct MessageJS {
@ -121,8 +121,11 @@ impl Message {
}
fn main() {
let mut args = env::args();
let _ = args.next();
let input_file = args.next().unwrap();
let messages: HashMap<String, MessageJS> =
serde_yaml::from_reader(File::open("test-data/messages.yaml").unwrap()).unwrap();
serde_yaml::from_reader(File::open(input_file).unwrap()).unwrap();
let messages = messages
.into_iter()