diff --git a/README.md b/README.md index 4285fbc..c05dd72 100644 --- a/README.md +++ b/README.md @@ -2007,6 +2007,21 @@ $ just --summary test ``` +The `[private]` attributemaster may also be used to hide recipes without needing to change the name: + +```make +[private] +foo: + +bar: +``` + +```sh +$ just --list +Available recipes: + bar +``` + This is useful for helper recipes which are only meant to be used as dependencies of other recipes. ### Quiet Recipes diff --git a/src/attribute.rs b/src/attribute.rs index c205f34..ffd532f 100644 --- a/src/attribute.rs +++ b/src/attribute.rs @@ -10,6 +10,7 @@ pub(crate) enum Attribute { Macos, NoCd, NoExitMessage, + Private, Unix, Windows, } diff --git a/src/recipe.rs b/src/recipe.rs index 5fda449..fa0aedb 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -63,7 +63,7 @@ impl<'src, D> Recipe<'src, D> { } pub(crate) fn public(&self) -> bool { - !self.private + !self.private && !self.attributes.contains(&Attribute::Private) } pub(crate) fn change_directory(&self) -> bool { diff --git a/tests/lib.rs b/tests/lib.rs index e6c7ed4..11d4d19 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -65,6 +65,7 @@ mod no_exit_message; mod os_attributes; mod parser; mod positional_arguments; +mod private; mod quiet; mod quote; mod readme; diff --git a/tests/private.rs b/tests/private.rs new file mode 100644 index 0000000..82e3d4f --- /dev/null +++ b/tests/private.rs @@ -0,0 +1,19 @@ +use super::*; + +#[test] +fn attribute() { + Test::new() + .justfile( + " + [private] + foo: + ", + ) + .args(&["--list"]) + .stdout( + " + Available recipes: + ", + ) + .run(); +}