Sharing `just` arguments between invocations
- Dominant language
- Rust
- Stars
- 35.8k
- Forks
- 846
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
In a previous version `--command-color` was added to allow coloring the command that is run in the stdout output. This works well but it not transferred to inner calls to `just`:
```just
inner arg:
just something {{ arg }}
something arg:
echo {{ arg }}
```
```bash
just --color-command red inner "I am a teapot"
just something "I am a teapot" # <--- colored red
echo "I am a teapot" # <--- not colored red
I am a teapot
```
Looking at the manual, this is not something that is easily done right now. It can also cause problems with `--yes`: top level recipes will be automatically confirmed but not inner ones
I see at leastfour possible solutions:
1) Allow configuring just through individual env vars: e.g, `JUST_CONFIRM="yes"` or `JUST_COMMAND_COLOR="red"` which would be automatically read
2) Allow configuring just through a single env vars: `JUST_EXTRA_ARGS="--yes --command-color red"` which would be automatically read
3) Add a function to inherit args in inner commands: `just just_args() something ...` in the recipe above
4) Add a setting to inherit args in inner commands: `set inherit-just-args := true`
I'm unsure which is the best. The env vars solutions will make it easy to share arguments, for example in CI scripts but could be surprising (maybe a log at the start, saying "using ... from env" ?). It's already something done by lots of programs though, so I don't think that's too bad.
Solutions 3 and 4 have the issue that they need to be set in each Justfile to work, which will be frustrating when adding a new one in a subdirectory for example. Solution 3 especially needs to be set on each invocation, which is quite invasive but offers lots of control.
Contributor guide
Research direction
Start by reproducing the nested `just` invocation shown in the issue and read the manual sections covering `--command-color` and `--yes`. Compare the four proposed inheritance approaches and determine which behavior should be selected; done means the chosen approach consistently shares the relevant arguments with inner invocations without unexpected effects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100