mirror of
https://github.com/casey/just.git
synced 2025-07-07 09:35:01 +00:00
Add [openbsd]
recipe attribute (#2497)
This commit is contained in:
parent
cdf104bf8c
commit
563eee6609
6 changed files with 38 additions and 19 deletions
|
@ -48,9 +48,9 @@ Yay, all your tests passed!
|
|||
[`make`'s complexity and idiosyncrasies](#what-are-the-idiosyncrasies-of-make-that-just-avoids).
|
||||
No need for `.PHONY` recipes!
|
||||
|
||||
- Linux, MacOS, and Windows are supported with no additional dependencies.
|
||||
(Although if your system doesn't have an `sh`, you'll need to
|
||||
[choose a different shell](#shell).)
|
||||
- Linux, MacOS, Windows, and other reasonable unices are supported with no
|
||||
additional dependencies. (Although if your system doesn't have an `sh`,
|
||||
you'll need to [choose a different shell](#shell).)
|
||||
|
||||
- Errors are specific and informative, and syntax errors are reported along
|
||||
with their source context.
|
||||
|
@ -1986,6 +1986,7 @@ change their behavior.
|
|||
| `[no-cd]`<sup>1.9.0</sup> | recipe | Don't change directory before executing recipe. |
|
||||
| `[no-exit-message]`<sup>1.7.0</sup> | recipe | Don't print an error message if recipe fails. |
|
||||
| `[no-quiet]`<sup>1.23.0</sup> | recipe | Override globally quiet recipes and always echo out the recipe. |
|
||||
| `[openbsd]`<sup>master</sup> | recipe | Enable recipe on OpenBSD. |
|
||||
| `[positional-arguments]`<sup>1.29.0</sup> | recipe | Turn on [positional arguments](#positional-arguments) for this recipe. |
|
||||
| `[private]`<sup>1.10.0</sup> | alias, recipe | Make recipe, alias, or variable private. See [Private Recipes](#private-recipes). |
|
||||
| `[script]`<sup>1.33.0</sup> | recipe | Execute recipe as script. See [script recipes](#script-recipes) for more details. |
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
`just` is a handy way to save and run project-specific commands.
|
||||
|
||||
Commands are stored in a file called `justfile` or `Justfile` with syntax inspired by `make`:
|
||||
Commands are stored in a file called `justfile` or `Justfile` with syntax
|
||||
inspired by `make`:
|
||||
|
||||
```make
|
||||
build:
|
||||
|
@ -15,8 +16,9 @@ test TEST: build
|
|||
./test --test {{TEST}}
|
||||
```
|
||||
|
||||
`just` produces detailed error messages and avoids `make`'s idiosyncrasies, so debugging a justfile is easier and less surprising than debugging a makefile.
|
||||
`just` produces detailed error messages and avoids `make`'s idiosyncrasies, so
|
||||
debugging a justfile is easier and less surprising than debugging a makefile.
|
||||
|
||||
It works on Linux, MacOS, and Windows.
|
||||
It works on all operating systems supported by Rust.
|
||||
|
||||
Read more on [GitHub](https://github.com/casey/just).
|
||||
|
|
|
@ -18,6 +18,7 @@ pub(crate) enum Attribute<'src> {
|
|||
NoCd,
|
||||
NoExitMessage,
|
||||
NoQuiet,
|
||||
Openbsd,
|
||||
PositionalArguments,
|
||||
Private,
|
||||
Script(Option<Interpreter<'src>>),
|
||||
|
@ -36,6 +37,7 @@ impl AttributeDiscriminant {
|
|||
| Self::NoCd
|
||||
| Self::NoExitMessage
|
||||
| Self::NoQuiet
|
||||
| Self::Openbsd
|
||||
| Self::PositionalArguments
|
||||
| Self::Private
|
||||
| Self::Unix
|
||||
|
@ -83,6 +85,7 @@ impl<'src> Attribute<'src> {
|
|||
AttributeDiscriminant::NoCd => Self::NoCd,
|
||||
AttributeDiscriminant::NoExitMessage => Self::NoExitMessage,
|
||||
AttributeDiscriminant::NoQuiet => Self::NoQuiet,
|
||||
AttributeDiscriminant::Openbsd => Self::Openbsd,
|
||||
AttributeDiscriminant::PositionalArguments => Self::PositionalArguments,
|
||||
AttributeDiscriminant::Private => Self::Private,
|
||||
AttributeDiscriminant::Script => Self::Script({
|
||||
|
@ -131,6 +134,7 @@ impl Display for Attribute<'_> {
|
|||
| Self::NoCd
|
||||
| Self::NoExitMessage
|
||||
| Self::NoQuiet
|
||||
| Self::Openbsd
|
||||
| Self::PositionalArguments
|
||||
| Self::Private
|
||||
| Self::Script(None)
|
||||
|
|
|
@ -113,17 +113,19 @@ impl<'src, D> Recipe<'src, D> {
|
|||
}
|
||||
|
||||
pub(crate) fn enabled(&self) -> bool {
|
||||
let windows = self.attributes.contains(&Attribute::Windows);
|
||||
let linux = self.attributes.contains(&Attribute::Linux);
|
||||
let macos = self.attributes.contains(&Attribute::Macos);
|
||||
let openbsd = self.attributes.contains(&Attribute::Openbsd);
|
||||
let unix = self.attributes.contains(&Attribute::Unix);
|
||||
let windows = self.attributes.contains(&Attribute::Windows);
|
||||
|
||||
(!windows && !linux && !macos && !unix)
|
||||
|| (cfg!(target_os = "windows") && windows)
|
||||
(!windows && !linux && !macos && !openbsd && !unix)
|
||||
|| (cfg!(target_os = "linux") && (linux || unix))
|
||||
|| (cfg!(target_os = "macos") && (macos || unix))
|
||||
|| (cfg!(windows) && windows)
|
||||
|| (cfg!(target_os = "openbsd") && (openbsd || unix))
|
||||
|| (cfg!(target_os = "windows") && windows)
|
||||
|| (cfg!(unix) && unix)
|
||||
|| (cfg!(windows) && windows)
|
||||
}
|
||||
|
||||
fn print_exit_message(&self) -> bool {
|
||||
|
|
|
@ -6,9 +6,10 @@ fn all() {
|
|||
.justfile(
|
||||
"
|
||||
[macos]
|
||||
[windows]
|
||||
[linux]
|
||||
[openbsd]
|
||||
[unix]
|
||||
[windows]
|
||||
[no-exit-message]
|
||||
foo:
|
||||
exit 1
|
||||
|
@ -48,7 +49,7 @@ fn multiple_attributes_one_line() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos, windows,linux]
|
||||
[macos,windows,linux,openbsd]
|
||||
[no-exit-message]
|
||||
foo:
|
||||
exit 1
|
||||
|
@ -64,7 +65,7 @@ fn multiple_attributes_one_line_error_message() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos, windows linux]
|
||||
[macos,windows linux,openbsd]
|
||||
[no-exit-message]
|
||||
foo:
|
||||
exit 1
|
||||
|
@ -73,10 +74,10 @@ fn multiple_attributes_one_line_error_message() {
|
|||
.stderr(
|
||||
"
|
||||
error: Expected ']', ':', ',', or '(', but found identifier
|
||||
——▶ justfile:1:17
|
||||
——▶ justfile:1:16
|
||||
│
|
||||
1 │ [macos, windows linux]
|
||||
│ ^^^^^
|
||||
1 │ [macos,windows linux,openbsd]
|
||||
│ ^^^^^
|
||||
",
|
||||
)
|
||||
.status(1)
|
||||
|
@ -88,7 +89,7 @@ fn multiple_attributes_one_line_duplicate_check() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos, windows, linux]
|
||||
[macos, windows, linux, openbsd]
|
||||
[linux]
|
||||
foo:
|
||||
exit 1
|
||||
|
|
|
@ -47,6 +47,10 @@ fn os() {
|
|||
[linux]
|
||||
foo:
|
||||
echo quxx
|
||||
|
||||
[openbsd]
|
||||
foo:
|
||||
echo bob
|
||||
",
|
||||
)
|
||||
.stdout(if cfg!(target_os = "macos") {
|
||||
|
@ -55,6 +59,8 @@ fn os() {
|
|||
"baz\n"
|
||||
} else if cfg!(target_os = "linux") {
|
||||
"quxx\n"
|
||||
} else if cfg!(target_os = "openbsd") {
|
||||
"bob\n"
|
||||
} else {
|
||||
panic!("unexpected os family")
|
||||
})
|
||||
|
@ -64,6 +70,8 @@ fn os() {
|
|||
"echo baz\n"
|
||||
} else if cfg!(target_os = "linux") {
|
||||
"echo quxx\n"
|
||||
} else if cfg!(target_os = "openbsd") {
|
||||
"echo bob\n"
|
||||
} else {
|
||||
panic!("unexpected os family")
|
||||
})
|
||||
|
@ -75,10 +83,11 @@ fn all() {
|
|||
Test::new()
|
||||
.justfile(
|
||||
"
|
||||
[macos]
|
||||
[windows]
|
||||
[linux]
|
||||
[macos]
|
||||
[openbsd]
|
||||
[unix]
|
||||
[windows]
|
||||
foo:
|
||||
echo bar
|
||||
",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue