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

Allow running recipes *after* another recipe #819

Closed
3 tasks
casey opened this issue May 7, 2021 · 1 comment · Fixed by #820
Closed
3 tasks

Allow running recipes *after* another recipe #819

casey opened this issue May 7, 2021 · 1 comment · Fixed by #820

Comments

@casey
Copy link
Owner

casey commented May 7, 2021

It's come up a few times that people would like to run recipes after another recipe. If there's a good way to do this that isn't weird and doesn't have surprising behavior, I think this would be a good feature.

There are a few open questions:

  • Should a post-dependency run if it has already been run in the current just invocation? Normal recipes and dependencies will run at most once, even if multiple recipes run that have them as a dependency. However, from the feature requests asking to be able to run recipes after another recipe, people seem to want post-dependencies to always run, so that's what I'm leaning for. I'm thinking of treating each post-dependency invocation as an independent just invocation.

  • Should a post-dependency run if the recipe fails? I'm thinking that at first it shouldn't, but we can add syntax later that will make a recipe run after another recipe, even if that recipe fails.

  • What should the syntax be? This is yet another case that I wish we had Add extensible recipe and justfile annotations #604, since then we could make it an annotation at first and punt on the syntax.

An idea for the syntax is to appropriate && and || from sh:

foo:
  echo foo

# foo only runs after bar if it succeeds
bar: && foo
  echo bar

# foo runs after baz regardless of whether or not it succeeds
baz: || foo
  echo qux

# foo runs after qux if it succeeds, bar runs after foo regardless
qux: && foo || bar
  echo qux

Downsides:

  • It is terse and cryptic
  • && and || require a little bit of thought to understand why they work how they do

Upsides:

  • It is terse and cryptic
  • If you're used to it from shell/perl/python/whatever, it makes a lot of sense
@casey casey linked a pull request May 7, 2021 that will close this issue
@casey
Copy link
Owner Author

casey commented May 7, 2021

I started working on this and calling them "subsequents". If recipes are allowed to have themselves as subsequents, this allows recursion, which is a step on the way towards making Just turing complete. (#792)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant