Skip to content

feat(run): support -- separator to pass extra args to typed-arg tasks#5569

Merged
ruben-arts merged 9 commits intoprefix-dev:mainfrom
ruben-arts:feat/run-double-dash-separator
Mar 3, 2026
Merged

feat(run): support -- separator to pass extra args to typed-arg tasks#5569
ruben-arts merged 9 commits intoprefix-dev:mainfrom
ruben-arts:feat/run-double-dash-separator

Conversation

@ruben-arts
Copy link
Contributor

@ruben-arts ruben-arts commented Feb 27, 2026

Description

Before we wouldn't be able to tell things to a task with args anymore, this PR would allow for users to use the -- to tell pixi to split it up and still allow the trailing args like normal. e.g.:

[tasks.test]
cmd = "pytest tests/{{ folder }} -x auto"
args = [{ arg = "folder", default = "unit" }]
pixi run test -- -v --tb=short --maxfail=5

The logic is:
If the run command is a pixi task, split of the first -- and use everything behind that as trailing args.
If the run command is not a pixi task, forward the -- to the command.

[tasks.echo-arg]
cmd = "echo {{ arg }}!"
args = ["arg"]

[tasks.echo-no-arg]
cmd = "echo hi"
# This will still work
> pixi run echo foo -- bar
foo -- bar
# Strip `--` for tasks
> pixi run echo-arg foo -- bar
foo! bar

# Don't strip `--` if it's not the first thing after the task name.
> pixi run echo-no-arg foo -- bar
hi foo -- bar

> pixi run echo-no-arg -- foobar
hi foobar

Related: #4208

How Has This Been Tested?

Tested it locally.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • [na] I have verified that changes that would impact the JSON schema have been made in schema/model.py.

ruben-arts and others added 3 commits February 27, 2026 09:10
When a task defines typed `args`, all CLI values are matched against
those definitions and any extras caused a `TooManyArguments` error.
This adds support for the standard `--` separator: everything after
`--` is forwarded verbatim to the underlying command, regardless of
the task's `args` definition.

    pixi run pytest tests/unit -- -v --tb=short --maxfail=5

For tasks without typed args (FreeFormArgs), `--` is preserved and
passed through unchanged so programs that use `--` themselves
(e.g. `git log -- somefile`) continue to work.

Implementation:
- Add `ArgValues::TypedArgsWithExtra(Vec<TypedArg>, Vec<String>)` variant
  to represent typed args combined with extra passthrough args
- Parse `--` separator in `TaskGraph::from_cmd_args` before arg resolution
- Update script generation in `ExecutableTask` to append extra args
- Add four unit tests covering the new behaviour
- Document the feature in the CLI reference and advanced tasks guide

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ruben-arts ruben-arts added the area:run Related to pixi run label Feb 27, 2026
@ruben-arts ruben-arts marked this pull request as draft February 27, 2026 10:01
@ruben-arts ruben-arts marked this pull request as ready for review February 27, 2026 10:35
Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs weren't completely accurate and I found some small improvements in the code.

Looks great to me, awesome work Ruben!

@Hofer-Julian Hofer-Julian force-pushed the feat/run-double-dash-separator branch from 9538a0a to 08725c6 Compare March 3, 2026 14:04
@ruben-arts ruben-arts enabled auto-merge (squash) March 3, 2026 14:09
@ruben-arts ruben-arts merged commit 9a5f03b into prefix-dev:main Mar 3, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:run Related to pixi run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants