Fix printing

Add padding opt to print_list
i18n
Michal S 2 years ago committed by Michal
parent bc80df4946
commit c9aff94b8e

@ -22,9 +22,12 @@ impl From<pacmanconf::Error> for Error {
}
}
#[tracing::instrument(level = "trace")]
pub fn get_handler() -> Result<Alpm, Error> {
let config = Config::from_file(Path::new("/etc/pacman.conf"))?;
let alpm = alpm_with_conf(&config)?;
tracing::debug!("Initialized alpm handler");
Ok(alpm)
}

@ -91,7 +91,12 @@ impl LogHandler {
}
}
pub fn print_list<I: IntoIterator<Item = T>, T: Display>(&self, list: I, separator: &str) {
pub fn print_list<I: IntoIterator<Item = T>, T: Display>(
&self,
list: I,
separator: &str,
padding: usize,
) {
let lines = list
.into_iter()
.map(|l| self.preformat_msg(l.to_string()))
@ -99,7 +104,7 @@ impl LogHandler {
format!("{}{}{}", acc, separator, line)
});
let lines = wrap_text(lines, 2).join("\n");
let lines = wrap_text(lines, padding).join("\n");
self.log(lines)
}

@ -36,7 +36,7 @@ pub async fn print_dependency_list(dependencies: &[DependencyInformation]) -> bo
let mut empty = true;
if !deps_repo.is_empty() {
tracing::info!("Repo dependencies");
get_logger().print_list(&deps_repo, " ");
get_logger().print_list(&deps_repo, " ", 2);
empty = false;
get_logger().print_newline();
}
@ -49,7 +49,7 @@ pub async fn print_dependency_list(dependencies: &[DependencyInformation]) -> bo
if !makedeps_repo.is_empty() {
tracing::info!("Repo make dependencies");
get_logger().print_list(&makedeps_repo, " ");
get_logger().print_list(&makedeps_repo, " ", 2);
empty = false;
get_logger().print_newline();
}
@ -94,7 +94,8 @@ pub async fn print_aur_package_list(packages: &[&PackageInfo]) -> bool {
.magenta()
)
}),
"\n ",
"\n",
2,
);
!installed.is_empty()

@ -8,6 +8,7 @@ use crate::args::{InstallArgs, Operation, QueryArgs, RemoveArgs, SearchArgs};
use crate::internal::detect;
use crate::internal::exit_code::AppExitCode;
use crate::internal::{sort, start_sudoloop, structs::Options};
use crate::logging::get_logger;
use crate::logging::Printable;
use clap_complete::{Generator, Shell};
@ -131,7 +132,8 @@ async fn cmd_search(args: SearchArgs, options: Options) {
tracing::info!("No results found");
} else {
tracing::info!("Results:");
let list: Vec<String> = results.iter().map(|x| x.to_print_string()).collect();
get_logger().print_list(list, "\n", 0);
}
}

@ -59,11 +59,11 @@ impl Printable for PackageSearchResult {
.timestamp(self.out_of_date.unwrap().try_into().unwrap(), 0)
.date_naive()
)
.bold()
.red()
} else {
"".bold()
};
"".to_string()
}
.bold()
.red();
let description = wrap_text(&self.description, 4).join("\n");
format!("{repo}{name} {version} {group} {out_of_date}\n {description}")

Loading…
Cancel
Save