strongloop / node-foreman

A Node.js Version of Foreman
http://strongloop.github.io/node-foreman/
Other
1.27k stars 119 forks source link

How to handle nf run child process options #154

Closed bertBruynooghe closed 6 years ago

bertBruynooghe commented 6 years ago

In: nf run testcafe \"chrome:headless\" ./*.js --screenshots ./

--screenshots is considered as an option of nf iso. testcafe.

I believe the original foreman fixes this by only considering options directly following the run parameter.

rmg commented 6 years ago

Use -- to tell the option parser to stop parsing options/flags:

nf run -- testcafe chrome:headless ./*.js --screenshots ./

This tells the option parser in nf to stop parsing options at -- and treat everything after it as standard positional arguments (aka, unprocessed strings).

I was curious how foreman supported this, since what you described is somewhat non-standard behaviour for a CLI program, so I just took a look. The Thor gem it uses for CLI parsing has a #stop_on_unknown_option! method in the API that does pretty much what it says.

...1 hour** of internet archeology later

Fun fact: the -- convention (per getopt(1) and getopt(3)) for stopping parsing CLI args was first documented in the AT&T System V Users Manual from 1983 😮


** ok, it was more like 3 hours, and was very entertaining 😊

bertBruynooghe commented 6 years ago

👍