pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Validate task args

Open bollwyvl opened this issue 8 months ago • 2 comments

Problem description

per https://github.com/prefix-dev/pixi/issues/3533#issuecomment-2783696643:

I would love if args also had a richer model to help projects write maintainable, self-documenting tasks:

[tasks.foo-one--]
cmd = "echo built {{ bar }} > bar/{{ bar }}.txt"
args = [
  { "arg" = "bar", default = "baz", description = "the foo to bar", enum=["baz", "boo"], regex="(baz|boo)" }
]

These would be lovely to see in a pixi task help foo, and give good feedback:

$> pixi r foo-one-- --bar poo

`foo-one--` argument `--bar` (the foo to bar) to was `poo`, but should be:
- one of `baz`, `boo`
- match the pattern `(baz|boo)`

Use `pixi task help foo-one--` to learn more.

bollwyvl avatar Apr 07 '25 15:04 bollwyvl

The original proposal also contained the enum key, and I am open to adding that.

Regarding regex, I'd like to think a bit more if regex or glob makes more sense here, so let's keep that out of that issue for now.

Hofer-Julian avatar Apr 08 '25 07:04 Hofer-Julian

Im wondering if we could reuse clap to do some of this processing? 🤔

baszalmstra avatar Apr 25 '25 07:04 baszalmstra