1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-04-20 20:26:50 +00:00

Add 'compact' option to get smaller output files

This commit is contained in:
Paul-Christian Volkmer 2023-06-07 10:55:55 +02:00
parent aa610a0593
commit ea135010d2
3 changed files with 14 additions and 4 deletions

View File

@ -34,6 +34,11 @@ Ohne Profildatei wird die Datei lediglich eingelesen, Leerzeichen am Ende eines
Ohne eine Angabe der Ausgabedatei wird auf die Standardausgabe ausgegeben. Ohne eine Angabe der Ausgabedatei wird auf die Standardausgabe ausgegeben.
#### Kompakte Ausgabe
OSC-Dateien sind XML-Dateien. Diese Anwendung ermöglicht optional die Ausgabe als kompaktere XML-Datei ohne Zeilenumbrüche.
Hierzu ist die Option `--compact` vorgesehen. Es können, je nach Datei, bis zu 30% eingespart werden.
## Profile ## Profile
Zum Erstellen von Varianten einer OSC-Datei wird eine Profildatei im YAML-Format verwendet. Zum Erstellen von Varianten einer OSC-Datei wird eine Profildatei im YAML-Format verwendet.

View File

@ -39,9 +39,11 @@ pub enum Command {
#[command(about = "Modifiziert die angegebene Datei anhand der Profildatei")] #[command(about = "Modifiziert die angegebene Datei anhand der Profildatei")]
Modify { Modify {
inputfile: String, inputfile: String,
#[arg(long = "profile", help = "Profildatei (Optional)")] #[arg(long = "profile", help = "Profildatei (optional)")]
profile: Option<String>, profile: Option<String>,
#[arg(long = "output", help = "Ausgabedatei (Optional)")] #[arg(long = "output", help = "Ausgabedatei (optional)")]
outputfile: Option<String>, outputfile: Option<String>,
#[arg(long = "compact", help = "Kompakte Ausgabe, ohne Einrücken (Optional)")]
compact: bool,
}, },
} }

View File

@ -117,6 +117,7 @@ fn main() -> Result<(), Box<dyn Error>> {
inputfile, inputfile,
profile, profile,
outputfile, outputfile,
compact,
} => { } => {
let data = &mut read_inputfile(inputfile)?; let data = &mut read_inputfile(inputfile)?;
@ -130,7 +131,9 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut buf = String::new(); let mut buf = String::new();
let mut serializer = Serializer::new(&mut buf); let mut serializer = Serializer::new(&mut buf);
if !compact {
serializer.indent(' ', 2); serializer.indent(' ', 2);
}
data.serialize(serializer).expect("Generated XML"); data.serialize(serializer).expect("Generated XML");