joerdav / xc

Markdown defined task runner.
https://xcfile.dev/
MIT License
1.04k stars 25 forks source link

Using variadic inputs to pass cli arguments #88

Closed nsbruce closed 1 year ago

nsbruce commented 1 year ago

I'm not sure if this is an anti-pattern or a bug. I'm trying to use a task for both testing during local development as well as generating a test report in a CI pipeline.


<!-- README.md -->

## Tasks

### test

```bash
poetry run pytest $@

When I am testing locally I can run `xc test` no problem. If I have the CI run `xc test --junitxml=junit.xml` I get this error:

```bash
xc: failed to compose script: invalid option: "--"
joerdav commented 1 year ago

Hi @nsbruce , thanks for using xc!

Flags passed as xc test --junitxml=junit.xml would be attempted to be processed by xc, as xc options, rather than passed to a task.

To pass variadic options including flags, you should be be able to do the following: xc test -- --junitxml=junit.xml.

Hope this helps!

nsbruce commented 1 year ago

That works! Thanks!

joerdav commented 1 year ago

Awesome! Also, I wouldn't call doing it this way an antipattern, I want xc to be flexible for how people want to use it, but the idea is to make these things as clear as possible for someone approaching your project.

Maybe splitting into another task would be clearer: xc test and xc test-xml.