just icon indicating copy to clipboard operation
just copied to clipboard

Allow inverted cfg attributes, like `[not(macos)]`

Open casey opened this issue 1 year ago • 2 comments

casey avatar Feb 11 '24 19:02 casey

reposting https://github.com/casey/just/issues/604#issuecomment-1934922523:

[@]casey are there any discussions on doing cargo style [not(condition)]/[condition] annotations?:

[not(windows)]
run:
  cc main.c
  ./a.out
  
[windows]
run:
  cl main.c
  main.exe

I imagine my usecase is quite common for some when dealing with doing/avoiding setup specific to CI environments:

[env_var("CI") == "true"]
run:
  ./do_the_ci_setup.sh
  ./run.sh

[not(env_var("CI") == "true")]
run:
  ./run.sh

mkatychev avatar Feb 13 '24 21:02 mkatychev

This would be very useful. My use case is for shell detection:


[env_var("SHELL") == "bash"]
tips:
  @echo "Setup your shell like this:"

[env_var("SHELL") == "zsh"]
tips:
  @echo "Setup your shell like this:"

Although, for shell detection, it would be nice to have built-in attributes like we have for os detection, e.g.


[bash]
tips:
  @echo "Setup your shell like this:"

[zsh]
tips:
  @echo "Setup your shell like this:"

[ps1]
tips:
  Write-Host "Setup your shell like this:"

With shell detection attributes, one could even have recipes per-shell. The current shell options set the global shell interpreter for the file, but with shell attributes, we can support multiple different shells in the same justfile. This can probably become its own feature request. Maybe this request is related to #531.

W1M0R avatar Jun 20 '24 13:06 W1M0R