Skip to content

Commit 2d9ebb5

Browse files
committed
Use yaml instead of toml for config.
1 parent fc1adb5 commit 2d9ebb5

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

java-spaghetti-gen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ clap = { version = "4", features = ["derive"] }
1414
bitflags = "2.8.0"
1515
serde = "1.0.197"
1616
serde_derive = "1.0.197"
17-
toml = "0.8.10"
1817
zip = "4.1.0"
1918
quote = "1.0.40"
2019
proc-macro2 = "1.0.95"
2120
anyhow = "1.0.98"
21+
serde_yaml = "0.9.34"
2222

2323
[dev-dependencies]
2424
jni-sys = "0.4.0"

java-spaghetti-gen/src/config.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! java-spaghetti.toml configuration file structures and parsing APIs.
1+
//! java-spaghetti.yaml configuration file structures and parsing APIs.
22
33
use std::path::{Path, PathBuf};
44
use std::{fs, io};
@@ -135,18 +135,19 @@ pub struct Config {
135135
}
136136

137137
impl Config {
138-
/// Read from I/O, under the assumption that it's in the "java-spaghetti.toml" file format.
139-
/// `directory` is the directory that contained the `java-spaghetti.toml` file, against which paths should be resolved.
138+
/// Read from I/O, under the assumption that it's in the "java-spaghetti.yaml" file format.
139+
/// `directory` is the directory that contained the `java-spaghetti.yaml` file, against which paths should be resolved.
140140
pub fn read(file: &mut impl io::Read, dir: &Path) -> io::Result<Self> {
141141
let mut buffer = String::new();
142-
file.read_to_string(&mut buffer)?; // Apparently toml can't stream.
142+
file.read_to_string(&mut buffer)?; // Apparently yaml can't stream.
143143
Self::read_str(&buffer[..], dir)
144144
}
145145

146-
/// Read from a memory buffer, under the assumption that it's in the "java-spaghetti.toml" file format.
147-
/// `directory` is the directory that contained the `java-spaghetti.toml` file, against which paths should be resolved.
146+
/// Read from a memory buffer, under the assumption that it's in the "java-spaghetti.yaml" file format.
147+
/// `directory` is the directory that contained the `java-spaghetti.yaml` file, against which paths should be resolved.
148148
pub fn read_str(buffer: &str, dir: &Path) -> io::Result<Self> {
149-
let mut config: Config = toml::from_str(buffer).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
149+
let mut config: Config =
150+
serde_yaml::from_str(buffer).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
150151

151152
if config.rules.is_empty() {
152153
config.rules.push(Rule {
@@ -165,20 +166,20 @@ impl Config {
165166
Ok(config)
166167
}
167168

168-
/// Search the current directory - or failing that, it's ancestors - until we find "java-spaghetti.toml" or reach the
169+
/// Search the current directory - or failing that, it's ancestors - until we find "java-spaghetti.yaml" or reach the
169170
/// root of the filesystem and cannot continue.
170171
#[allow(dead_code)]
171172
pub fn from_current_directory() -> io::Result<Self> {
172173
Self::from_directory(std::env::current_dir()?.as_path())
173174
}
174175

175-
/// Search the specified directory - or failing that, it's ancestors - until we find "java-spaghetti.toml" or reach the
176+
/// Search the specified directory - or failing that, it's ancestors - until we find "java-spaghetti.yaml" or reach the
176177
/// root of the filesystem and cannot continue.
177178
pub fn from_directory(path: &Path) -> io::Result<Self> {
178179
let original = path;
179180
let mut path = path.to_owned();
180181
loop {
181-
path.push("java-spaghetti.toml");
182+
path.push("java-spaghetti.yaml");
182183
println!("cargo:rerun-if-changed={}", path.display());
183184
if path.exists() {
184185
return Config::read(&mut fs::File::open(&path)?, path.parent().unwrap());
@@ -187,7 +188,7 @@ impl Config {
187188
Err(io::Error::new(
188189
io::ErrorKind::NotFound,
189190
format!(
190-
"Failed to find java-spaghetti.toml in \"{}\" or any of it's parent directories.",
191+
"Failed to find java-spaghetti.yaml in \"{}\" or any of it's parent directories.",
191192
original.display()
192193
),
193194
))?;

0 commit comments

Comments
 (0)