0

I want to express below data via CLI parameters:

[
 {
    taskName: "preProcessMarkup",
    entryPointsGroups: [ "open", "admin", "emails" ]
 },
 {
    taskName: "preProcessStyles",
    entryPointsGroups: [ "open", "admin" ]
 }
]

It would be something like:

builder buildProject --taskName preProcessMarkup // ... here goes the 
// related with task "preProcessMarkup"

Please teach me the correct syntax or suggest the alternatives.

Notes

  • This question not about how to parse commands. This question about how to write commands.
  • My application is being written by Node.js. I don't know how far CLI syntax is unified.
Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124

1 Answers1

2

You could do something like:

$ builder buildProject --taskName preProcessMarkup --entryPointsGroup open --entryPointsGroup admin --entryPointsGroup emails --taskName preProcessStyles --entryPointsGroup open --entryPointsGroup admin

and parsing it;

or something accepting comma separated lists, something like:

$ builder buildProject --taskName preProcessMarkup --entryPointsGroups open,admin,emails --taskName preProcessStyles --entryPointsGroups open,admin

and again parsing it;

but I would suggest to follow the KISS principle and doing something like:

$ builder buildProject '[{"taskName":"preProcessMarkup","entryPointsGroups":["open","admin","emails"]},{"taskName":"preProcessStyles","entryPointsGroups":["open","admin"]}]'

and then parsing it simply with a JSON.parse.

Daniele Ricci
  • 15,422
  • 1
  • 27
  • 55