Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit bbe2f2f

Browse files
committed
CLI: add summary info to iXML in --format=list
1 parent 8fc32ea commit bbe2f2f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

wavrw-cli/src/bin/wavrw.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ fn view_line(file: BufReader<File>) -> Result<String> {
203203
chunk.data.sample_loops.len()
204204
));
205205
}
206+
// special case iXML to show certain keys
207+
Ok(SizedChunkEnum::Ixml(chunk)) => {
208+
chunk_strings.push(format!("{}[{}]", chunk.name(), chunk.summary()));
209+
}
206210
// match on id() to catch all current and future LIST variants
207211
Ok(chunk) if chunk.id() == b"LIST" => {
208212
chunk_strings.push(format!("{}[{}]", chunk.name(), chunk.summary()));

wavrw/src/chunk/ixml/aswg.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ pub struct Aswg {
298298
}
299299

300300
impl Aswg {
301+
/// User friendly name of the element's key
302+
pub fn name(&self) -> String {
303+
"ASWG".to_string()
304+
}
305+
301306
/// Create a new Aswg struct.
302307
pub fn new() -> Self {
303308
Aswg {

wavrw/src/chunk/ixml/mod.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -259,21 +259,12 @@ impl Default for Ixml {
259259

260260
impl Summarizable for Ixml {
261261
fn summary(&self) -> String {
262-
let mut out = Vec::<&String>::new();
263-
let fields = format!("{} keys", self.items().count());
264-
if let Some(value) = &self.project {
265-
out.push(value);
266-
}
267-
if let Some(value) = &self.scene {
268-
out.push(value);
269-
}
270-
if let Some(value) = &self.tape {
271-
out.push(value);
272-
}
273-
if let Some(value) = &self.take {
274-
out.push(value);
275-
}
276-
format!("{}: {}, ...", fields, out.into_iter().join(", "))
262+
let mut keys = Vec::<String>::new();
263+
// TODO: SPEED, LOUDNESS, HISTORY, FILE_SET, TRACK_LIST, BEXT, USER, LOCATION
264+
if let Some(ref aswg) = self.aswg {
265+
keys.push(aswg.name());
266+
};
267+
format!("{}: {}, ...", self.items().count(), keys.join(", "),)
277268
}
278269

279270
fn items<'a>(&'a self) -> Box<dyn Iterator<Item = (String, String)> + 'a> {
@@ -303,7 +294,7 @@ impl Summarizable for Ixml {
303294
// structs and extra items
304295
if let Some(aswg) = &self.aswg {
305296
for (k, v) in aswg.items() {
306-
items.push((format!("ASWG/{}", k), v));
297+
items.push((format!("{}/{}", aswg.name(), k), v));
307298
}
308299
}
309300

0 commit comments

Comments
 (0)