|
2 | 2 | use crate::command::core::run_read_entries_mem; |
3 | 3 | use crate::{ |
4 | 4 | chunk, |
5 | | - cli::{FileArgsCompat, PasswordArgs}, |
| 5 | + cli::{ColorChoice, FileArgsCompat, PasswordArgs}, |
6 | 6 | command::{ |
7 | 7 | Command, ask_password, |
8 | 8 | core::{PathFilter, collect_split_archives, read_paths, run_read_entries}, |
@@ -52,6 +52,8 @@ use tabled::{ |
52 | 52 | group(ArgGroup::new("null-requires").arg("null").requires("exclude_from")), |
53 | 53 | )] |
54 | 54 | pub(crate) struct ListCommand { |
| 55 | + #[arg(skip)] |
| 56 | + pub(crate) color: ColorChoice, |
55 | 57 | #[arg(short, long, help = "Display extended file metadata as a table")] |
56 | 58 | pub(crate) long: bool, |
57 | 59 | #[arg(short, long, help = "Add a header row to each column")] |
@@ -286,6 +288,7 @@ fn list_archive(args: ListCommand) -> anyhow::Result<()> { |
286 | 288 | classify: args.classify, |
287 | 289 | format: args.format, |
288 | 290 | out_to_stderr: false, |
| 291 | + color: args.color, |
289 | 292 | }; |
290 | 293 | let archive = args.file.archive(); |
291 | 294 | let files = args.file.files(); |
@@ -365,6 +368,7 @@ pub(crate) struct ListOptions { |
365 | 368 | pub(crate) classify: bool, |
366 | 369 | pub(crate) format: Option<Format>, |
367 | 370 | pub(crate) out_to_stderr: bool, |
| 371 | + pub(crate) color: ColorChoice, |
368 | 372 | } |
369 | 373 |
|
370 | 374 | pub(crate) fn run_list_archive<'a>( |
@@ -444,9 +448,11 @@ fn print_entries<'a>( |
444 | 448 | .collect::<Vec<_>>(); |
445 | 449 | globs.ensure_all_matched()?; |
446 | 450 | if options.out_to_stderr { |
447 | | - print_formatted_entries(entries, &options, io::stderr().lock()) |
| 451 | + let out = anstream::AutoStream::new(io::stderr().lock(), options.color.into()); |
| 452 | + print_formatted_entries(entries, &options, out) |
448 | 453 | } else { |
449 | | - print_formatted_entries(entries, &options, io::stdout().lock()) |
| 454 | + let out = anstream::AutoStream::new(io::stdout().lock(), options.color.into()); |
| 455 | + print_formatted_entries(entries, &options, out) |
450 | 456 | } |
451 | 457 | } |
452 | 458 |
|
|
0 commit comments