casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
18.52k stars 421 forks source link

Allow pattern matching on task signatures #1894

Open trashhalo opened 4 months ago

trashhalo commented 4 months ago

Instead of doing a chain of if else if statements I think the justfile syntax would be cleaner if it supported pattern matching

kubectl "staging" "app" *args:
  Kubectl --context=dhdhdjd -n djdjsjdj-app {{ args }}

kubectl "prod" "app" *args:
# etcetc

Vs

kubectl env service *args:
  context = if env == "staging" { "djfjfnfn} # else if for every env
  deployment = if app == # etc etc
casey commented 4 months ago

The syntax would probably have to be something like:

kubectl @staging @app *args:

And not arbitrary strings, just because of the way the parser works. This is a cool feature, although it might be quite a large change to how recipe dispatch works.