pakker-cli: add some color to pakker ls
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Iaac69f7b97115154875ef4ac3949cfae6a6a6964
This commit is contained in:
parent
1efbbe0353
commit
6ffcfb5af6
1 changed files with 33 additions and 11 deletions
|
|
@ -1,5 +1,7 @@
|
|||
use std::path::Path;
|
||||
|
||||
use yansi::Paint;
|
||||
|
||||
use crate::{cli::LsArgs, error::Result, model::LockFile};
|
||||
|
||||
/// Truncate a name to fit within `max_len` characters, adding "..." if
|
||||
|
|
@ -20,11 +22,15 @@ pub fn execute(args: &LsArgs, lockfile_path: &Path) -> Result<()> {
|
|||
let lockfile = LockFile::load(lockfile_dir)?;
|
||||
|
||||
if lockfile.projects.is_empty() {
|
||||
println!("No projects installed");
|
||||
println!("{}", "No projects installed".yellow());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
println!("Installed projects ({}):", lockfile.projects.len());
|
||||
println!(
|
||||
"{} ({})",
|
||||
"Installed projects".bold(),
|
||||
lockfile.projects.len().to_string().cyan().bold()
|
||||
);
|
||||
println!();
|
||||
|
||||
// Calculate max name length for alignment
|
||||
|
|
@ -53,28 +59,39 @@ pub fn execute(args: &LsArgs, lockfile_path: &Path) -> Result<()> {
|
|||
if args.detailed {
|
||||
let id = project.pakku_id.as_deref().unwrap_or("unknown");
|
||||
let name = truncate_name(&project.get_name(), max_name_len);
|
||||
println!(" {name} ({id}){version_warning}");
|
||||
println!(" Type: {:?}", project.r#type);
|
||||
println!(" Side: {:?}", project.side);
|
||||
let name_line = format!(" {name} ({id})");
|
||||
if version_warning.is_empty() {
|
||||
println!("{}", name_line.bold());
|
||||
} else {
|
||||
println!("{}{}", name_line.bold(), version_warning.yellow());
|
||||
}
|
||||
println!(" {} {:?}", "Type:".dim(), project.r#type);
|
||||
println!(" {} {:?}", "Side:".dim(), project.side);
|
||||
|
||||
if let Some(file) = project.files.first() {
|
||||
println!(" File: {}", file.file_name);
|
||||
println!(" {} {}", "File:".dim(), file.file_name);
|
||||
println!(
|
||||
" Version: {} ({})",
|
||||
file.release_type, file.date_published
|
||||
" {} {} ({})",
|
||||
"Version:".dim(),
|
||||
file.release_type,
|
||||
file.date_published
|
||||
);
|
||||
}
|
||||
|
||||
// Show version details if there's a mismatch
|
||||
if !version_warning.is_empty() {
|
||||
println!(" Provider versions:");
|
||||
println!(" {}:", "Provider versions".dim());
|
||||
for file in &project.files {
|
||||
println!(" {}: {}", file.file_type, file.file_name);
|
||||
}
|
||||
}
|
||||
|
||||
if !project.pakku_links.is_empty() {
|
||||
println!(" Dependencies: {}", project.pakku_links.len());
|
||||
println!(
|
||||
" {} {}",
|
||||
"Dependencies:".dim(),
|
||||
project.pakku_links.len()
|
||||
);
|
||||
}
|
||||
|
||||
println!();
|
||||
|
|
@ -86,7 +103,12 @@ pub fn execute(args: &LsArgs, lockfile_path: &Path) -> Result<()> {
|
|||
.map(|f| format!(" ({})", f.file_name))
|
||||
.unwrap_or_default();
|
||||
|
||||
println!(" {name}{file_info}{version_warning}");
|
||||
println!(
|
||||
" {}{}{}",
|
||||
name.bold(),
|
||||
file_info.dim(),
|
||||
version_warning.yellow()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue