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