`<ADDITIONAL_JOB_ARGS>` are passed to `cargo check` when switch from `run` to `check` task
Hi,
If I execute bacon run -- foo, and then press Ctrl+d to switch to the default task (i.e., run), I get the following error:
error: unexpected argument 'foo' found
Usage: cargo check [OPTIONS]
For more information, try '--help'.
Basically, cargo check doesn't allow additional arguments.
This could also be true for other tasks (e.g., test), but I'm not sure.
Do you suggest the arguments after the double-slash (["foo"] in your example) should be given only to the initial job ?
And what if somebody wanted to have them given to all jobs ?
Opinions welcome
The thing is that cargo run -- foo is valid, and cargo check -- foo is not valid. cargo check rejects additional arguments, because that doesn't make sense (the application isn't run, so command line arguments are not used).
So I believe the correct thing to do, would be to just not pass additional arguments to tasks that don't support them. build probably doesn't support additional arguments, as well (because the app isn't run, so command line arguments are not used).
If the user switches back to a task that supports additional arguments (e.g. run), then the additional arguments would be used again.
Do you suggest the arguments after the double-slash (["foo"] in your example) should be given only to the initial job ?
Ideally, additional command line arguments would be given to all tasks that accept them, but not others.
And what if somebody wanted to have them given to all jobs ?
This wouldn't work, because check for example just returns an error if someone passes in additional command line arguments for the application.
cargo check does accept additional arguments.
You can do this today :
bacon check -- --all-targets --features "myfeature"
So bacon would have to know whether the arguments are used by the job executable in a direct manner or not ?
Ah, I see. I thought the -- of bacon is like the -- of cargo.
However, that doesn't change much. In this case, the issue is with bacon run -- $ADDITIONAL_TASK_ARGS -- $ADDITIONAL_PROGRAM_ARGS (e.g. bacon run -- -- foo).
-- $ADDITIONAL_PROGRAM_ARGS should not be passed to tasks that don't allow additional command line arguments.
So bacon would have to know whether the arguments are used by the job executable in a direct manner or not ?
Cargo allows additional command line arguments (without the --) as long as they don't conflict with Cargos command line options. So in theory Bacon would need to figure out what arguments are intended for Cargo and which are intended for the application.
But I think, it would be reasonable for Bacon to require -- -- for passing additional arguments to the application.