How to compare numbers outside of recipe context?
- Dominant language
- Rust
- Stars
- 35.8k
- Forks
- 846
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
I would like to do some numbers comparison, specifically comparing numbers of cpus returned by `num_cpus()` function, but really have troubles with that.
Here is an example of `justfile`:
```justfile
DEFAULT_THREADS = 8
threads := env('THREADS', DEFAULT_THREADS)
run:
RUSTFLAGS="-Z threads={{ threads }}" cargo build
```
What I would like to is to replace logic in `env('THREADS', DEFAULT_THREADS)` to something like
```justfile
env('THREADS', if num_cpus() > DEFAULT_THREADS { DEFAULT_THREADS } else { num_cpus() })
```
Moving that check to recipe context isn't an option as there are many recipes to update and for some of them the call is complex already.
What I tried:
- resort to shell context with ``, but then I can't interpolate `DEFAULT_THREADS` and use `num_cpus()`.
- use another private `just` recipe for calculation in shell context and call it then ```env('THREADS', `just _do_calculation`)```, but `just` falls into recursive loop I think and I haven't found how to avoid it without passing even more extra parameters of setting and checking some flags.
Is it possible to do this or we have to add new things to `just` for that?
Thank you in advance!
Contributor guide
Assessment
This issue has not been assessed yet.