mise
mise copied to clipboard
More templating options for run commands in tasks
Hi,
I have migrated my noxfile to mise and everything works fine except for one case:
I'd like to adjust my task's run command based on parameters like env vars or arguments. For example, locally I like my linter to fix errors, while in CI it should fail.
For now I have a .mise.toml file like:
[tasks."format:ruff"]
description = "Format the code with ruff"
run = """
#!/usr/bin/env bash
if [ "$CI" == "yes" ]; then
ruff format myproject tests --check
else
ruff format myproject tests
fi
"""
...
[tasks.ci]
alias = "default"
description = "Run all CI tasks"
depends = ["format", "lint", "test"]
However, I would like to have something like:
[tasks."format:ruff"]
description = "Format the code with ruff"
run = "ruff format myproject tests {{ if args.ci: '--check' }}"
I understand tasks are still experimental, so thanks for considering this anyway.
yeah this would be nice. One of the things I'm planning is a far more advanced arg parsing logic leveraging the work I'm doing with usage. No idea when I'll have time to finish that but this would be a good addition.