-
-
Notifications
You must be signed in to change notification settings - Fork 201
Description
Is your feature request related to a problem? Please describe.
Yes. Currently, when passing arguments to a task via the CLI using the passthrough separator (--), moon run appends these arguments to the ones already defined in the moon.yml configuration.
This creates a problem when the default arguments defined in the configuration (optimized for CI or standard usage) conflict with the ad-hoc arguments needed for local development.
For example, if a test task is configured with args: ['run', '--coverage'], running moon run project:test -- watch results in the command vitest run --coverage watch. This often fails or behaves unexpectedly because the default flags clash with the manual intention (running in watch mode without coverage).
tasks:
test:
command: "vitest"
args:
- "run"
- "--coverage"Describe the solution you'd like
I would like a CLI flag (e.g., --replace-args, --overwrite, or similar) for the moon run command or an additional option on moon tasks like mergeArgs do for inheritance.
When this flag is used, moon should completely ignore the args list defined in the task's YAML configuration and only use the arguments provided after the -- separator.
Example:
Command: moon run project:test --replace-args -- watch
Executed command: vitest watch (ignoring any args defined in moon.yml)
Describe alternatives you've considered
- Creating duplicate tasks: Defining multiple variants of the same task in
moon.yml(e.g.,testvstest-watch). This leads to configuration bloat and maintenance overhead just to support different CLI flags. - Removing defaults: Removing arguments from
moon.ymlentirely and relying on scripts or always typing full commands, which negates the convenience of moon for CI pipelines.
Additional context
Here is a another example of the limitation:
moon.yml:
tasks:
build:
command: "webpack"
args:
- "--mode=production"
- "--analyze"Current behavior:
moon run project:build -- --mode=development- Executes:
webpack --mode=production --analyze --mode=development(The order might matter, or flags might conflict).
Desired behavior with feature:
moon run project:build --replace-args -- --mode=development- Executes:
webpack --mode=development