mirror of
https://github.com/casey/just.git
synced 2024-11-25 07:06:23 +03:00
List recipes by group in group justfile order with just --list --unsorted
(#2164)
This commit is contained in:
parent
4a59769faa
commit
197e1002d0
@ -500,7 +500,17 @@ impl Subcommand {
|
||||
groups
|
||||
};
|
||||
|
||||
for (i, (group, recipes)) in groups.iter().enumerate() {
|
||||
let mut ordered = module
|
||||
.public_groups(config)
|
||||
.into_iter()
|
||||
.map(Some)
|
||||
.collect::<Vec<Option<String>>>();
|
||||
|
||||
if groups.contains_key(&None) {
|
||||
ordered.insert(0, None);
|
||||
}
|
||||
|
||||
for (i, group) in ordered.into_iter().enumerate() {
|
||||
if i > 0 {
|
||||
println!();
|
||||
}
|
||||
@ -509,14 +519,14 @@ impl Subcommand {
|
||||
|
||||
if !no_groups {
|
||||
print!("{list_prefix}");
|
||||
if let Some(group_name) = group {
|
||||
println!("[{group_name}]");
|
||||
if let Some(group) = &group {
|
||||
println!("[{group}]");
|
||||
} else {
|
||||
println!("(no group)");
|
||||
}
|
||||
}
|
||||
|
||||
for recipe in recipes {
|
||||
for recipe in groups.get(&group).unwrap() {
|
||||
for (i, name) in iter::once(&recipe.name())
|
||||
.chain(aliases.get(recipe.name()).unwrap_or(&Vec::new()))
|
||||
.enumerate()
|
||||
|
@ -96,6 +96,47 @@ fn list_with_groups_unsorted() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_with_groups_unsorted_group_order() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[group('y')]
|
||||
[group('x')]
|
||||
f:
|
||||
|
||||
[group('b')]
|
||||
b:
|
||||
|
||||
[group('a')]
|
||||
e:
|
||||
|
||||
c:
|
||||
",
|
||||
)
|
||||
.args(["--list", "--unsorted"])
|
||||
.stdout(
|
||||
"
|
||||
Available recipes:
|
||||
(no group)
|
||||
c
|
||||
|
||||
[x]
|
||||
f
|
||||
|
||||
[y]
|
||||
f
|
||||
|
||||
[b]
|
||||
b
|
||||
|
||||
[a]
|
||||
e
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_groups() {
|
||||
Test::new()
|
||||
|
Loading…
Reference in New Issue
Block a user