move command group printing logic into function
this makes the print function a bit cleaner.
This commit is contained in:
parent
7f36560e25
commit
e93b201d77
1 changed files with 28 additions and 18 deletions
|
@ -5,16 +5,7 @@ use shared::{errors::Error, names::Site};
|
|||
|
||||
use crate::arguments::PrintGroup;
|
||||
|
||||
pub(crate) fn print(path: &Path, group: &PrintGroup, seperator: &Option<char>) -> Result<(), Error> {
|
||||
let names_file = names::read_names_file(path)?;
|
||||
let names = names::load_names(names_file)?;
|
||||
|
||||
Ok(for site in names {
|
||||
if !group.url && !group.name {
|
||||
log::info!("{:?}", site);
|
||||
continue;
|
||||
}
|
||||
|
||||
fn group_printing(seperator: &Option<char>, site: Site, group: &PrintGroup) {
|
||||
let mut string = String::new();
|
||||
let delimiter = seperator.unwrap_or(',');
|
||||
|
||||
|
@ -31,7 +22,26 @@ pub(crate) fn print(path: &Path, group: &PrintGroup, seperator: &Option<char>) -
|
|||
}
|
||||
|
||||
log::info!("{}", string);
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn print(
|
||||
path: &Path,
|
||||
group: &PrintGroup,
|
||||
seperator: &Option<char>,
|
||||
) -> Result<(), Error> {
|
||||
let names_file = names::read_names_file(path)?;
|
||||
let names = names::load_names(names_file)?;
|
||||
|
||||
for site in names {
|
||||
if !group.url && !group.name {
|
||||
log::info!("{:?}", site);
|
||||
continue;
|
||||
}
|
||||
|
||||
group_printing(seperator, site, group);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn add(path: &Path, url: &String, name: &Option<String>) -> Result<(), Error> {
|
||||
|
|
Loading…
Reference in a new issue