Skip to content

Commit

Permalink
Ignore [private] recipes in just --list (#1816)
Browse files Browse the repository at this point in the history
  • Loading branch information
crdx authored and casey committed Jan 12, 2024
1 parent 251fb7a commit 6eb2060
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl<'src> Justfile<'src> {
.recipes
.values()
.map(AsRef::as_ref)
.filter(|recipe| recipe.public())
.filter(|recipe| recipe.is_public())
.collect::<Vec<&Recipe<Dependency>>>();

if source_order {
Expand Down
2 changes: 1 addition & 1 deletion src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<'src, D> Recipe<'src, D> {
Ok(())
}

pub(crate) fn public(&self) -> bool {
pub(crate) fn is_public(&self) -> bool {
!self.private && !self.attributes.contains(&Attribute::Private)
}

Expand Down
2 changes: 1 addition & 1 deletion src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ impl Subcommand {
let mut line_widths: BTreeMap<&str, usize> = BTreeMap::new();

for (name, recipe) in &justfile.recipes {
if recipe.private {
if !recipe.is_public() {
continue;
}

Expand Down
31 changes: 31 additions & 0 deletions tests/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,37 @@ fn module_paths_beginning_with_tilde_are_expanded_to_homdir() {
.run();
}

#[test]
fn module_recipe_list_alignment_ignores_private_recipes() {
Test::new()
.write(
"foo.just",
"
# foos
foo:
@echo FOO
[private]
barbarbar:
@echo BAR
@_bazbazbaz:
@echo BAZ
",
)
.justfile("mod foo")
.test_round_trip(false)
.arg("--unstable")
.arg("--list")
.stdout(
"Available recipes:
foo:
foo # foos
",
)
.run();
}

#[test]
fn recipes_with_same_name_are_both_run() {
Test::new()
Expand Down

0 comments on commit 6eb2060

Please sign in to comment.