{"_id":"@abcb-cafe/node-getopt","name":"@abcb-cafe/node-getopt","dist-tags":{"latest":"0.3.2-a"},"versions":{"0.3.2-a":{"name":"@abcb-cafe/node-getopt","version":"0.3.2-a","author":{"name":"Jiang Miao","email":"jiangfriend@gmail.com"},"description":"featured command line args parser","keywords":["getopt","arg","parser"],"homepage":"https://github.com/jiangmiao/node-getopt","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jiangmiao/node-getopt.git"},"main":"index.js","engines":{"node":">= 0.6.0"},"gitHead":"fcc1ee399d5776d1c3917bef743126d245e7b4c6","bugs":{"url":"https://github.com/jiangmiao/node-getopt/issues"},"_id":"@abcb-cafe/node-getopt@0.3.2-a","_nodeVersion":"16.18.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-dRHRxx6iwN9ORGkJGEeQGDjCVMF/39Z/3zOzCGKxtYN0hxGfMde2PYQN6C00qGheFkjBub3gAwRUwgYk2S8hkA==","shasum":"0fef7ded6d4e15f017a698a8ada927020789e013","tarball":"https://registry.npmjs.org/@abcb-cafe/node-getopt/-/node-getopt-0.3.2-a.tgz","fileCount":12,"unpackedSize":39885,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDgyCJeg6qSg+7iSqPLoQn8PBbvwWg0C6X+zwuuUz8k/wIhAKC8PFmQjSQepMUH7vTqKa5Z4j94ZoRDaBy3BXN/fOWZ"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjcEtEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo6ZQ//Shhj43oI5KFZQRBWnJw8lJJBJUN3Wj+2NbYs6krrv/dZ3h8g\r\ngzstWrkcdFDgAP1KdYMPzWZJflChFyS420WcIWgXNQse2H3oNuvjmhOzhXWf\r\nzdqQK4QnAGKaJTCIcjsOGT/I8kp0Q4PCCVgULq6tO056Ohj7ZSOWZOl16qBM\r\njVHSSdP3Jo9ttC3LzhhWvAAWoU6olaVLbVu3rx10fUOAlkNhvs7VHpot3Zr2\r\ncKa9rT+qZhdbokQXss0X59TC8bDbnmkAvO/TXuGNnLMg0trCYfZRO2D113YM\r\ntDz5lt54k8G6nfzJRbmpHocyNFmeDfF6mWA2zECooU4u5uKmR9Mg5E/Wx486\r\nWDwSlBNRvkphw4/cDENRZBDMp8EgMM02U4/II8HckqLyvvcrCemNVbxUtlWs\r\n2Ga+tR6ZzMxcT8E//1POeLg0CZiVGL2h5crh4fv0gydMB8TgCRwPLBnRjFlw\r\nfnUnXVB24wyICxPw31wj75Wuc+aRILzOJ5L5/FFa1Q7FTKcpRzRGFFWBolBF\r\n+pVp5LZRhZthLjKH7Qfa20p4GTOATqNsTNDiRSsvvu7SLlrD1yHZzSKUQOWy\r\nZoHOPN7AjKiZx/llMV1ykyoOnqI8YRL2cXiSxPLzRZDMmpEgZX6BHAVw5yop\r\nMKAvDq0Q9UuUSJ9ydu1cwBAjFOQVflpkcNo=\r\n=4wm5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"jimmyhwang","email":"jimmyhwang.tw@gmail.com"},"directories":{},"maintainers":[{"name":"jimmyhwang","email":"jimmyhwang.tw@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-getopt_0.3.2-a_1668303684693_0.4505343880028858"},"_hasShrinkwrap":false}},"time":{"created":"2022-11-13T01:41:24.645Z","0.3.2-a":"2022-11-13T01:41:24.875Z","modified":"2022-11-13T01:41:25.042Z"},"maintainers":[{"name":"jimmyhwang","email":"jimmyhwang.tw@gmail.com"}],"description":"featured command line args parser","homepage":"https://github.com/jiangmiao/node-getopt","keywords":["getopt","arg","parser"],"repository":{"type":"git","url":"git+https://github.com/jiangmiao/node-getopt.git"},"author":{"name":"Jiang Miao","email":"jiangfriend@gmail.com"},"bugs":{"url":"https://github.com/jiangmiao/node-getopt/issues"},"license":"MIT","readme":"node-getopt\r\n===========\r\nFeatured command line parser.\r\n\r\nBasic Usage\r\n-----------\r\n\r\n**Parse Commandline**\r\n\r\ncode: oneline.js\r\n\r\n    // node-getopt oneline example.\r\n    opt = require('node-getopt').create([\r\n      ['s' , ''                    , 'short option.'],\r\n      [''  , 'long'                , 'long option.'],\r\n      ['S' , 'short-with-arg=ARG'  , 'option with argument', 'S'],\r\n      ['L' , 'long-with-arg=ARG'   , 'long option with argument'],\r\n      [''  , 'color[=COLOR]'       , 'COLOR is optional'],\r\n      ['m' , 'multi-with-arg=ARG+' , 'multiple option with argument'],\r\n      [''  , 'no-comment'],\r\n      ['h' , 'help'                , 'display this help'],\r\n      ['v' , 'version'             , 'show version']\r\n    ])              // create Getopt instance\r\n    .bindHelp()     // bind option 'help' to default action\r\n    .parseSystem(); // parse command line\r\n\r\n    console.info({argv: opt.argv, options: opt.options});\r\n\r\n`$ node oneline.js  foo -s --long-with-arg bar -m a -m b -- --others`\r\n\r\n    { argv: [ 'foo', '--others' ],\r\n      options:\r\n       { 'short-with-arg': 'S',\r\n         s: true,\r\n         'long-with-arg': 'bar',\r\n         'multi-with-arg': [ 'a', 'b' ],\r\n         S: 'S',\r\n         L: 'bar',\r\n         m: [ 'a', 'b' ] } }\r\n\r\n`$ node oneline.js -h`\r\n\r\n    Usage: node oneline.js\r\n\r\n      -s                         short option.\r\n          --long                 long option.\r\n      -S, --short-with-arg=ARG   option with argument\r\n      -L, --long-with-arg=ARG    long option with argument\r\n          --color[=COLOR]        COLOR is optional\r\n      -m, --multi-with-arg=ARG+  multiple option with argument\r\n          --no-comment\r\n      -h, --help                 display this help\r\n      -v, --version              show version\r\n\r\ncode: simple.js\r\n\r\n    // examples/simple.js\r\n    // argv parse\r\n    Getopt = require('node-getopt');\r\n\r\n    // Getopt arguments options\r\n    //   '=':   has argument\r\n    //   '[=]': has argument but optional\r\n    //   '+':   multiple option supported\r\n    getopt = new Getopt([\r\n      ['s'],\r\n      ['S' , '='],\r\n      [''  , 'long-with-arg=ARG'],\r\n      ['m' , '=+'],\r\n      [''  , 'color[=COLOR]'],\r\n      ['h' , 'help']\r\n    ]).bindHelp();\r\n\r\n    // process.argv needs slice(2) for it starts with 'node' and 'script name'\r\n    // parseSystem is alias  of parse(process.argv.slice(2))\r\n    // opt = getopt.parseSystem();\r\n    opt = getopt.parse(process.argv.slice(2));\r\n    console.info({argv: opt.argv, options: opt.options});\r\n\r\n`$ node simple.js foo -s --long-with-arg bar -m a -m b -- --others`\r\n\r\n    { argv: [ 'foo', '--others' ],\r\n      options: { s: true, 'long-with-arg': 'bar', m: [ 'a', 'b' ] } }\r\n\r\n**Work with help**\r\n\r\ncode: help.js\r\n\r\n    // examples/help.js\r\n    // Works with help\r\n    Getopt = require('node-getopt');\r\n\r\n    getopt = new Getopt([\r\n      ['s' , ''                    , 'short option.'],\r\n      [''  , 'long'                , 'long option.'],\r\n      ['S' , 'short-with-arg=ARG'  , 'option with argument', 'S'],\r\n      ['L' , 'long-with-arg=ARG'   , 'long option with argument'],\r\n      [''  , 'color[=COLOR]'       , 'COLOR is optional'],\r\n      ['m' , 'multi-with-arg=ARG+' , 'multiple option with argument'],\r\n      [''  , 'no-comment'],\r\n      ['h' , 'help'                , 'display this help']\r\n    ]);\r\n\r\n    // Use custom help template instead of default help\r\n    // [[OPTIONS]] is the placeholder for options list\r\n    getopt.setHelp(\r\n      \"Usage: node help.js [OPTION]\\n\" +\r\n      \"node-getopt help demo.\\n\" +\r\n      \"\\n\" +\r\n      \"[[OPTIONS]]\\n\" +\r\n      \"\\n\" +\r\n      \"Installation: npm install node-getopt\\n\" +\r\n      \"Respository:  https://github.com/jiangmiao/node-getopt\"\r\n    );\r\n\r\n    getopt.showHelp();\r\n\r\n`$ node examples/help.js`\r\n\r\n    Usage: node help.js [OPTION]\r\n    node-getopt help demo.\r\n\r\n      -s                         short option.\r\n          --long                 long option.\r\n      -S, --short-with-arg=ARG   option with argument          (default: S)\r\n      -L, --long-with-arg=ARG    long option with argument\r\n          --color[=COLOR]        COLOR is optional\r\n      -m, --multi-with-arg=ARG+  multiple option with argument\r\n          --no-comment\r\n      -h, --help                 display this help\r\n\r\n    Installation: npm install node-getopt\r\n    Respository:  https://github.com/jiangmiao/node-getopt\r\n\r\nFeatures\r\n--------\r\n\r\nshort option name\r\n\r\n    $ node simple.js -s\r\n    { argv: [], options: { short: true } }\r\n\r\n    $ node simple.js -S foo\r\n    { argv: [], options: { 'short-with-arg': 'foo' } }\r\n\r\nlong option name\r\n\r\n    $ node simple.js --long\r\n    { argv: [], options: { long: true } }\r\n\r\n    $ node simple.js --long-with-arg foo\r\n    { argv: [], options: { 'long-with-arg': 'foo' } }\r\n\r\nargument required\r\n\r\n    $ node simple.js --long-with-arg\r\n    ERROR: option long-with-arg need argument\r\n\r\n    $ node simple.js --long-with-arg foo\r\n    { argv: [], options: { 'long-with-arg': 'foo' } }\r\n\r\n    $ node simple.js --long-with-arg=foo\r\n    { argv: [], options: { 'long-with-arg': 'foo' } }\r\n\r\noptional argument\r\n\r\n    $ node simple.js --color\r\n    { argv: [], options: { color: '' } }\r\n\r\n    $ node simple.js --color=foo\r\n    { argv: [], options: { color: 'foo' } }\r\n\r\n    $ node simple.js --color foo\r\n    { argv: [ 'foo' ], options: { color: '' }\r\n\r\nchain option\r\n\r\n    $ node simple.js -slS foo\r\n    { argv: [],\r\n      options: { short: true, long: true, 'short-with-arg': 'foo' } }\r\n\r\n\r\nmulti option supported\r\n\r\n    $ node simple.js -m a -m b -m c\r\n    { argv: [], options: { 'multi-with-arg': [ 'a', 'b', 'c' ] } }\r\n\r\ntext argv supported\r\n\r\n    $ node simple.js foo -m a bar -m b baz -m c\r\n    { argv: [ 'foo', 'bar', 'baz' ],\r\n      options: { 'multi-with-arg': [ 'a', 'b', 'c' ] } }\r\n\r\nkeep text after --\r\n\r\n    $ node simple.js -s -- -s\r\n    { argv: [ '-s' ], options: { short: true } }\r\n\r\nReferences\r\n----------\r\n\r\n    require('node-getopt') returns class Getopt\r\n\r\nGetopt Methods:\r\n\r\n    constructor(Array options)\r\n        options is a set of option. each option contains 4 fields.\r\n        [short_name, long_name_with_definition, comment, default]\r\n        Definition:\r\n            * '=ARG':   has argument\r\n            * '[=ARG]': has argument but optional\r\n            * '+':      multiple option supported\r\n\r\n            ARG can be replaced by any word.\r\n\r\n    Getopt parse(Array argv)\r\n        parse argv\r\n\r\n        Returns: {argv: '...', options: {...}, ...}\r\n\r\n    Getopt parseSystem()\r\n        alias of parse(process.argv.slice(2))\r\n\r\n\r\n    Getopt setHelp(String helpTemplate)\r\n        Set help template. the placeholders will be replaced by getopt.\r\n\r\n        Placeholders:\r\n            * [[OPTIONS]] - The options list\r\n\r\n        Returns: String\r\n\r\n    String getHelp()\r\n        Get the help generated.\r\n\r\n    Getopt showHelp()\r\n        console.info(getopt.getHelp());\r\n\r\n    Getopt bindHelp([String HELP])\r\n        set help template to HELP if HELP is not empty.\r\n        bind 'help' option to default action, show help and exit with 0.\r\n\r\n    Getpot on(String optionName, Function<Value> action)\r\n        trigger the action when optionName is found.\r\n        the 'this' in action will be the instance of Getopt.\r\n\r\n    Getopt error(Function<Error e> callback)\r\n        when parse failed callback will be trigger. default is display error message and exit with 1.\r\n\r\n\r\nGetopt Static Methods:\r\n\r\n    create(Array options)\r\n        equals new Getopt(options)\r\n\r\nOthers:\r\n\r\n    default help template:\r\n\r\n        \"Usage: node #{process.argv[1].match(/(?:.*[\\/\\\\])?(.*)$/)[1]}\\n\\n[[OPTIONS]]\\n\"\r\n\r\nRemarks\r\n-------\r\n\r\n    v0.2.* is NOT compatible with v0.1.*\r\n","readmeFilename":"README.md"}