nomnom icon indicating copy to clipboard operation
nomnom copied to clipboard

New option type: map

Open gamtiq opened this issue 12 years ago • 1 comments

Hello,

It would be useful to implement support for new option type (a possible name is map) that will allow gathering values of options with specified prefix into object. Specification field map could have string or boolean value. In the former case string specifies prefix to detect appropriate options. In the case of true value prefix is equal to full option name (value of specification field full).

Example:

var opts = require("nomnom")
        .option('application', {
            map: 'app',
            help: 'Application data'
        })
        .option('build', {
            map: true,
            help: 'Build settings'
        })
        .parse();

So

--app-name=MyApp --app-dir=some/path --build-mode=standalone --build-target=browser

would give:

{
    "application": {
        "name": "MyApp",
        "dir": "some/path"
    },
    "build": {
        "mode": "standalone",
        "target": "browser"
    }
}

Thanks, Denis

gamtiq avatar Jan 28 '14 17:01 gamtiq

:+1:

aoberoi avatar Jun 04 '15 02:06 aoberoi