Hide recipes with [private] attribute (#1422)

This commit is contained in:
Casey Rodarmor 2022-11-22 16:25:57 -08:00 committed by GitHub
parent 6ff18af48f
commit 2b46af1cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 1 deletions

View File

@ -2007,6 +2007,21 @@ $ just --summary
test
```
The `[private]` attribute<sup>master</sup> 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

View File

@ -10,6 +10,7 @@ pub(crate) enum Attribute {
Macos,
NoCd,
NoExitMessage,
Private,
Unix,
Windows,
}

View File

@ -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 {

View File

@ -65,6 +65,7 @@ mod no_exit_message;
mod os_attributes;
mod parser;
mod positional_arguments;
mod private;
mod quiet;
mod quote;
mod readme;

19
tests/private.rs Normal file
View File

@ -0,0 +1,19 @@
use super::*;
#[test]
fn attribute() {
Test::new()
.justfile(
"
[private]
foo:
",
)
.args(&["--list"])
.stdout(
"
Available recipes:
",
)
.run();
}