rushstack
rushstack copied to clipboard
[rush] command-line.json supports specifying custom remainder for commands and phases
Summary
This PR proposes specifying custom remainder for commands and phases in "command-line.json"
Details
- Add "remainders" property in "command-line.json"
- Each item in "remainders" associates with commands or phases
- The associated commands/phases can get the argument list after recognized portion.
How it was tested
modify "common/config/rush/command-line.json"
"commands": [
{
"commandKind": "global",
"name": "echo",
"summary": "echo argv",
"shellCommand": "echo $@"
},
// ...
"remainders": [
{
"description": "rest arguments"
"associatedCommands": ["echo"]
}
]
Run node libraries/rush-lib/lib/start.js echo a b c, it prints
Run node libraries/rush-lib/lib/start.js echo -h, it prints
What happens when a command/phase is associated with two remainders?
My inclination would be to treat the remainder as a singleton that can be associated with commands or phases, and just have a hardcoded description.
What happens when a command/phase is associated with two remainders?
Yes. remainder should be a singleton. We should forbid (throw error) when declaring two remainders for the same command
My inclination would be to treat the remainder as a singleton that can be associated with commands or phases, and just have a hardcoded description.
Are you proposing something like the following?
common/config/rush/command-line.json
{
"remainders": { // a list of different remainders -> a object declares associated commands and/or phases
// no description setting at all
"associatedCommands": [ "FOO", "BAR" ] // should be unique
"associatedPhases": ["_phase:FOO", "_phase:BAR"] // should be unique
}
}
If so, the only concern is there is no way to archive the use case as follow:
"remainders": [
{
"associatedCommands": [ "FOO"]
"associatedPhases": ["_phase:FOO", "_phase:BAR"]
},
{
"associatedCommands": ["BAR" ]
"associatedPhases": ["_phase:BAR"]
}
]
custom remainder for _phase:FOO only for FOO command, but not for BAR command.
Maybe the use case is not a big deal (?)