fix bug in show
This commit is contained in:
+7
-2
@@ -170,11 +170,16 @@ impl Pacdef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show_group_content(&self, groups: &ArgMatches) -> Result<()> {
|
fn show_group_content(&self, groups: &ArgMatches) -> Result<()> {
|
||||||
let groups = groups.get_many::<String>("group").unwrap();
|
let mut iter = groups.get_many::<String>("group").unwrap().peekable();
|
||||||
for arg_group in groups {
|
|
||||||
|
while let Some(arg_group) = iter.next() {
|
||||||
let group = self.groups.iter().find(|g| g.name == *arg_group).unwrap();
|
let group = self.groups.iter().find(|g| g.name == *arg_group).unwrap();
|
||||||
println!("{group}");
|
println!("{group}");
|
||||||
|
if iter.peek().is_some() {
|
||||||
|
println!();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use std::fmt::Write;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -102,8 +103,13 @@ impl Display for Group {
|
|||||||
let mut sections: Vec<_> = self.sections.iter().collect();
|
let mut sections: Vec<_> = self.sections.iter().collect();
|
||||||
sections.sort_unstable();
|
sections.sort_unstable();
|
||||||
|
|
||||||
for section in sections {
|
let mut iter = sections.into_iter().peekable();
|
||||||
|
|
||||||
|
while let Some(section) = iter.next() {
|
||||||
section.fmt(f)?;
|
section.fmt(f)?;
|
||||||
|
if iter.peek().is_some() {
|
||||||
|
f.write_char('\n')?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user