Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ watch +args='test':
test:
cargo test

ci: build-book
ci: lint build-book
cargo test --all

lint:
cargo clippy --all --all-targets -- --deny warnings
cargo fmt --all -- --check
./bin/forbid
cargo fmt --all -- --check
cargo update --locked --package just

fuzz:
Expand Down
10 changes: 7 additions & 3 deletions src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,13 @@ impl Subcommand {
ordered.insert(0, None);
}

let no_groups = groups.contains_key(&None) && groups.len() == 1;

for (i, group) in ordered.into_iter().enumerate() {
if i > 0 {
println!();
}

let no_groups = groups.contains_key(&None) && groups.len() == 1;

if !no_groups {
print!("{list_prefix}");
if let Some(group) = &group {
Expand Down Expand Up @@ -605,7 +605,11 @@ impl Subcommand {
Self::list_module(config, submodule, depth + 1);
}
} 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());
format_doc(
config,
Expand Down
46 changes: 46 additions & 0 deletions tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,49 @@ fn module_doc_aligned() {
)
.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();
}