diff options
author | crdx <pub@crdx.org> | 2024-01-09 08:07:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 08:07:43 +0000 |
commit | 541e78104c6d9030f35751bcf6c59e85574314d3 (patch) | |
tree | 4a5f0d965ef70834f8a4c3e5ce7c359d12f0103a | |
parent | cf57613da74cdd896e3e2a86bd69445845af11ee (diff) |
Ignore [private] recipes in just --list (#1816)
-rw-r--r-- | src/justfile.rs | 2 | ||||
-rw-r--r-- | src/recipe.rs | 2 | ||||
-rw-r--r-- | src/subcommand.rs | 2 | ||||
-rw-r--r-- | tests/modules.rs | 31 |
4 files changed, 34 insertions, 3 deletions
diff --git a/src/justfile.rs b/src/justfile.rs index 55cc70df..0b862d29 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -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 { diff --git a/src/recipe.rs b/src/recipe.rs index 30e9d9ed..8f91bb01 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -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) } diff --git a/src/subcommand.rs b/src/subcommand.rs index ad016eb1..8dbcbaea 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -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; } diff --git a/tests/modules.rs b/tests/modules.rs index 63e067fe..75aaf7fc 100644 --- a/tests/modules.rs +++ b/tests/modules.rs @@ -686,6 +686,37 @@ fn module_paths_beginning_with_tilde_are_expanded_to_homdir() { } #[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() .write("foo.just", "bar:\n @echo MODULE") |