Print space before submodules in --list with groups (#2244)

This commit is contained in:
Casey Rodarmor 2024-07-13 19:20:35 -07:00 committed by GitHub
parent 458805e283
commit 6747c79082
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 57 additions and 5 deletions

View File

@ -16,11 +16,13 @@ watch +args='test':
test: test:
cargo test cargo test
ci: build-book ci: lint build-book
cargo test --all cargo test --all
lint:
cargo clippy --all --all-targets -- --deny warnings cargo clippy --all --all-targets -- --deny warnings
cargo fmt --all -- --check
./bin/forbid ./bin/forbid
cargo fmt --all -- --check
cargo update --locked --package just cargo update --locked --package just
fuzz: fuzz:

View File

@ -539,13 +539,13 @@ impl Subcommand {
ordered.insert(0, None); ordered.insert(0, None);
} }
let no_groups = groups.contains_key(&None) && groups.len() == 1;
for (i, group) in ordered.into_iter().enumerate() { for (i, group) in ordered.into_iter().enumerate() {
if i > 0 { if i > 0 {
println!(); println!();
} }
let no_groups = groups.contains_key(&None) && groups.len() == 1;
if !no_groups { if !no_groups {
print!("{list_prefix}"); print!("{list_prefix}");
if let Some(group) = &group { if let Some(group) = &group {
@ -605,7 +605,11 @@ impl Subcommand {
Self::list_module(config, submodule, depth + 1); Self::list_module(config, submodule, depth + 1);
} }
} else { } else {
for submodule in module.modules(config) { for (i, submodule) in module.modules(config).into_iter().enumerate() {
if !no_groups && !groups.is_empty() && i == 0 {
println!();
}
print!("{list_prefix}{} ...", submodule.name()); print!("{list_prefix}{} ...", submodule.name());
format_doc( format_doc(
config, config,

View File

@ -405,3 +405,49 @@ fn module_doc_aligned() {
) )
.run(); .run();
} }
#[test]
fn space_before_submodules_following_groups() {
Test::new()
.write("foo.just", "")
.justfile(
"
mod foo
[group: 'baz']
bar:
",
)
.test_round_trip(false)
.args(["--unstable", "--list"])
.stdout(
"
Available recipes:
[baz]
bar
foo ...
",
)
.run();
}
#[test]
fn no_space_before_submodules_not_following_groups() {
Test::new()
.write("foo.just", "")
.justfile(
"
mod foo
",
)
.test_round_trip(false)
.args(["--unstable", "--list"])
.stdout(
"
Available recipes:
foo ...
",
)
.run();
}