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

Add variable to have just require a program to be present on the system #2334

Closed
nogweii opened this issue Aug 30, 2024 · 1 comment
Closed

Comments

@nogweii
Copy link

nogweii commented Aug 30, 2024

As a command runner, it would be convenient to be able to specify the list of programs necessary for my Justfile to run. Something like the following example:

set required-programs := ["kubectl", "helm", "helmfile"]

bootstrap: && helm-charts
    kubectl apply -f foo.yaml

helm-charts:
    helmfile apply --file bar.yaml

status:
    helm ls -A

And if I didn't have those programs installed, just would error out before running a recipe with a helpful message saying that I need to install, say, helm & helmfile.

If this is added, I can imagine a need for [require-optional] (with a better name though) if people wanted to provide a recipe to install all the missing programs.

This is basically automatically doing #2109 and reporting an error. If that function is added, this could be solved by creating a recipe that does this. However, I still think it's worthwhile to include this feature.

@casey
Copy link
Owner

casey commented Aug 30, 2024

You could do this with a recipe:

require-dependencies:
  helm --version || echo "please install helm"

status: require-dependencies
    helm ls -A

This is more verbose, since you have to add that recipe as a dependency, but more flexible, since you can add that recipe as a dependency only to those recipes which require the binaries your checking for.

I think actually the way to support this is #2178, which would allow defining a recipe to be run before any other recipe in the justfile, which would allow for checking any kind of precondition, including whether or not particular binaries are installed.

@casey casey closed this as completed Aug 30, 2024
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

No branches or pull requests

2 participants