mirror of
https://github.com/casey/just.git
synced 2024-11-23 02:44:56 +03:00
Hide recipes with [private]
attribute (#1422)
This commit is contained in:
parent
6ff18af48f
commit
2b46af1cae
15
README.md
15
README.md
@ -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
|
||||
|
@ -10,6 +10,7 @@ pub(crate) enum Attribute {
|
||||
Macos,
|
||||
NoCd,
|
||||
NoExitMessage,
|
||||
Private,
|
||||
Unix,
|
||||
Windows,
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
19
tests/private.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn attribute() {
|
||||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[private]
|
||||
foo:
|
||||
",
|
||||
)
|
||||
.args(&["--list"])
|
||||
.stdout(
|
||||
"
|
||||
Available recipes:
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
Loading…
Reference in New Issue
Block a user