mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
ls: simplify extraction of indices
This commit is contained in:
committed by
Daniel Hofstetter
parent
742e8ca27f
commit
c8813c8331
@@ -311,9 +311,9 @@ fn extract_sort(options: &clap::ArgMatches) -> Sort {
|
||||
};
|
||||
|
||||
let sort_index = options
|
||||
.get_one::<String>(options::SORT)
|
||||
.and_then(|_| options.indices_of(options::SORT))
|
||||
.map_or(0, |mut indices| indices.next_back().unwrap_or(0));
|
||||
.indices_of(options::SORT)
|
||||
.and_then(|mut it| it.next_back())
|
||||
.unwrap_or(0);
|
||||
let time_index = get_last_index(options::sort::TIME);
|
||||
let size_index = get_last_index(options::sort::SIZE);
|
||||
let none_index = get_last_index(options::sort::NONE);
|
||||
@@ -427,9 +427,9 @@ fn extract_color(options: &clap::ArgMatches) -> bool {
|
||||
};
|
||||
|
||||
let color_index = options
|
||||
.get_one::<String>(options::COLOR)
|
||||
.and_then(|_| options.indices_of(options::COLOR))
|
||||
.map_or(0, |mut indices| indices.next_back().unwrap_or(0));
|
||||
.indices_of(options::COLOR)
|
||||
.and_then(|mut it| it.next_back())
|
||||
.unwrap_or(0);
|
||||
let unsorted_all_index = get_last_index(options::files::UNSORTED_ALL);
|
||||
|
||||
let color_enabled = match options.get_one::<String>(options::COLOR) {
|
||||
|
||||
Reference in New Issue
Block a user