mirror of
https://github.com/casey/just.git
synced 2025-12-23 11:37:29 +00:00
Merge 7317ad883a into 8eea534d01
This commit is contained in:
commit
4e813fc0a7
5 changed files with 24 additions and 7 deletions
|
|
@ -2142,6 +2142,7 @@ change their behavior.
|
|||
| `[doc(DOC)]`<sup>1.27.0</sup> | module, recipe | Set recipe or module's [documentation comment](#documentation-comments) to `DOC`. |
|
||||
| `[extension(EXT)]`<sup>1.32.0</sup> | recipe | Set shebang recipe script's file extension to `EXT`. `EXT` should include a period if one is desired. |
|
||||
| `[group(NAME)]`<sup>1.27.0</sup> | module, recipe | Put recipe or module in in [group](#groups) `NAME`. |
|
||||
| `[android]`<sup>1.43.0</sup> | recipe | Enable recipe on Android. |
|
||||
| `[linux]`<sup>1.8.0</sup> | recipe | Enable recipe on Linux. |
|
||||
| `[macos]`<sup>1.8.0</sup> | recipe | Enable recipe on MacOS. |
|
||||
| `[metadata(METADATA)]`<sup>1.42.0</sup> | recipe | Attach `METADATA` to recipe. |
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use super::*;
|
|||
#[strum_discriminants(derive(EnumString, Ord, PartialOrd))]
|
||||
#[strum_discriminants(strum(serialize_all = "kebab-case"))]
|
||||
pub(crate) enum Attribute<'src> {
|
||||
Android,
|
||||
Confirm(Option<StringLiteral<'src>>),
|
||||
Default,
|
||||
Doc(Option<StringLiteral<'src>>),
|
||||
|
|
@ -35,7 +36,8 @@ impl AttributeDiscriminant {
|
|||
fn argument_range(self) -> RangeInclusive<usize> {
|
||||
match self {
|
||||
Self::Confirm | Self::Doc => 0..=1,
|
||||
Self::Default
|
||||
Self::Android
|
||||
| Self::Default
|
||||
| Self::ExitMessage
|
||||
| Self::Linux
|
||||
| Self::Macos
|
||||
|
|
@ -84,6 +86,7 @@ impl<'src> Attribute<'src> {
|
|||
}
|
||||
|
||||
Ok(match discriminant {
|
||||
AttributeDiscriminant::Android => Self::Android,
|
||||
AttributeDiscriminant::Confirm => Self::Confirm(arguments.into_iter().next()),
|
||||
AttributeDiscriminant::Default => Self::Default,
|
||||
AttributeDiscriminant::Doc => Self::Doc(arguments.into_iter().next()),
|
||||
|
|
@ -133,7 +136,8 @@ impl Display for Attribute<'_> {
|
|||
write!(f, "{}", self.name())?;
|
||||
|
||||
match self {
|
||||
Self::Confirm(None)
|
||||
Self::Android
|
||||
| Self::Confirm(None)
|
||||
| Self::Default
|
||||
| Self::Doc(None)
|
||||
| Self::ExitMessage
|
||||
|
|
|
|||
|
|
@ -134,13 +134,15 @@ impl<'src, D> Recipe<'src, D> {
|
|||
}
|
||||
|
||||
pub(crate) fn enabled(&self) -> bool {
|
||||
let android = self.attributes.contains(AttributeDiscriminant::Android);
|
||||
let linux = self.attributes.contains(AttributeDiscriminant::Linux);
|
||||
let macos = self.attributes.contains(AttributeDiscriminant::Macos);
|
||||
let openbsd = self.attributes.contains(AttributeDiscriminant::Openbsd);
|
||||
let unix = self.attributes.contains(AttributeDiscriminant::Unix);
|
||||
let windows = self.attributes.contains(AttributeDiscriminant::Windows);
|
||||
|
||||
(!windows && !linux && !macos && !openbsd && !unix)
|
||||
(!windows && !android && !linux && !macos && !openbsd && !unix)
|
||||
|| (cfg!(target_os = "android") && (android || unix))
|
||||
|| (cfg!(target_os = "linux") && (linux || unix))
|
||||
|| (cfg!(target_os = "macos") && (macos || unix))
|
||||
|| (cfg!(target_os = "openbsd") && (openbsd || unix))
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ fn all() {
|
|||
[macos]
|
||||
[linux]
|
||||
[openbsd]
|
||||
[android]
|
||||
[unix]
|
||||
[windows]
|
||||
[no-exit-message]
|
||||
|
|
@ -49,7 +50,7 @@ fn multiple_attributes_one_line() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos,windows,linux,openbsd]
|
||||
[macos,windows,linux,openbsd,android]
|
||||
[no-exit-message]
|
||||
foo:
|
||||
exit 1
|
||||
|
|
@ -65,7 +66,7 @@ fn multiple_attributes_one_line_error_message() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos,windows linux,openbsd]
|
||||
[macos,windows linux,openbsd,android]
|
||||
[no-exit-message]
|
||||
foo:
|
||||
exit 1
|
||||
|
|
@ -76,7 +77,7 @@ fn multiple_attributes_one_line_error_message() {
|
|||
error: Expected ']', ':', ',', or '(', but found identifier
|
||||
——▶ justfile:1:16
|
||||
│
|
||||
1 │ [macos,windows linux,openbsd]
|
||||
1 │ [macos,windows linux,openbsd,android]
|
||||
│ ^^^^^
|
||||
",
|
||||
)
|
||||
|
|
@ -89,7 +90,7 @@ fn multiple_attributes_one_line_duplicate_check() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos, windows, linux, openbsd]
|
||||
[macos, windows, linux, openbsd, android]
|
||||
[linux]
|
||||
foo:
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -51,6 +51,10 @@ fn os() {
|
|||
[openbsd]
|
||||
foo:
|
||||
echo bob
|
||||
|
||||
[android]
|
||||
foo:
|
||||
echo babs
|
||||
",
|
||||
)
|
||||
.stdout(if cfg!(target_os = "macos") {
|
||||
|
|
@ -61,6 +65,8 @@ fn os() {
|
|||
"quxx\n"
|
||||
} else if cfg!(target_os = "openbsd") {
|
||||
"bob\n"
|
||||
} else if cfg!(target_os = "android") {
|
||||
"babs\n"
|
||||
} else {
|
||||
panic!("unexpected os family")
|
||||
})
|
||||
|
|
@ -72,6 +78,8 @@ fn os() {
|
|||
"echo quxx\n"
|
||||
} else if cfg!(target_os = "openbsd") {
|
||||
"echo bob\n"
|
||||
} else if cfg!(target_os = "android") {
|
||||
"echo babs\n"
|
||||
} else {
|
||||
panic!("unexpected os family")
|
||||
})
|
||||
|
|
@ -83,6 +91,7 @@ fn all() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[android]
|
||||
[linux]
|
||||
[macos]
|
||||
[openbsd]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue