Format files properly again

I forgot to include the includes and time zone commands
This commit is contained in:
Joscha 2021-11-22 10:20:17 +00:00
parent d7df47eba4
commit 2c7aa78d08
5 changed files with 72 additions and 23 deletions

View file

@ -273,14 +273,28 @@ impl fmt::Display for Command {
impl fmt::Display for File {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut commands = self.commands.iter();
if let Some(command) = commands.next() {
write!(f, "{}", command)?;
for command in commands {
writeln!(f)?;
write!(f, "{}", command)?;
}
let mut empty = true;
for include in &self.includes {
writeln!(f, "INCLUDE {}", include)?;
empty = false;
}
if let Some(tz) = &self.timezone {
if !empty {
writeln!(f)?;
}
writeln!(f, "TIMEZONE {}", tz)?;
empty = false;
}
for command in &self.commands {
if !empty {
writeln!(f)?;
}
write!(f, "{}", command)?;
empty = false;
}
Ok(())
}
}