Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS Recipe Attributes #1387

Merged
merged 10 commits into from
Oct 31, 2022
Merged

OS Recipe Attributes #1387

merged 10 commits into from
Oct 31, 2022

Conversation

casey
Copy link
Owner

@casey casey commented Oct 28, 2022

This adds [linux], [macos], [windows], and [unix] recipe OS attributes.

By default, without an OS attribute, a recipe is enabled on all operating systems. With an OS attribute, a recipe is only enabled when being run by a version of just build for that OS. Note that this depends on the OS the just binary was built for, not the OS that it's running on. So recipes with [linux] in a justfile run by ajust binary built for Linux but running on the Windows Subsystem for Linux be enabled.

This allows writing cross-platform justfiles by writing multiple recipes with the same name which are enabled on different OSes. For example:

[windows]
foo:
  echo bar

[unix]
foo:
  echo baz

On Windows, just foo will print bar and on linux just foo will print baz.

Recipes with the [unix] attribute are enabled on all unices, including Linux and MacOS.

Todo:

  • Document in readme

@casey casey changed the title OS Recipe Annotations OS Recipe Attributes Oct 28, 2022
Copy link

@esiegel esiegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super simple. Looks good to me.


#[test]
fn to_str() {
assert_eq!(Attribute::NoExitMessage.to_str(), "no-exit-message");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add the same test for all of the enums, though not sure if it tests much.

@casey casey merged commit 73777f7 into master Oct 31, 2022
@casey casey deleted the os-specific-recipes branch October 31, 2022 07:52
@casey casey mentioned this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants