package.json 13.2 KB
Newer Older
Muddsair Sharif's avatar
Muddsair Sharif committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
  "_args": [
    [
      {
        "raw": "commander@2",
        "scope": null,
        "escapedName": "commander",
        "name": "commander",
        "rawSpec": "2",
        "spec": ">=2.0.0 <3.0.0",
        "type": "range"
      },
      "C:\\Users\\Giuliano\\worldwind\\nasaworldwind\\node\\node_modules\\d3-dsv"
    ]
  ],
  "_from": "commander@>=2.0.0 <3.0.0",
  "_id": "commander@2.10.0",
  "_inCache": true,
  "_location": "/commander",
  "_nodeVersion": "6.10.1",
  "_npmOperationalInternal": {
    "host": "s3://npm-registry-packages",
    "tmp": "tmp/commander-2.10.0.tgz_1498210375405_0.9538901860360056"
  },
  "_npmUser": {
    "name": "abetomo",
    "email": "abe@enzou.tokyo"
  },
  "_npmVersion": "5.0.3",
  "_phantomChildren": {},
  "_requested": {
    "raw": "commander@2",
    "scope": null,
    "escapedName": "commander",
    "name": "commander",
    "rawSpec": "2",
    "spec": ">=2.0.0 <3.0.0",
    "type": "range"
  },
  "_requiredBy": [
    "/d3-dsv"
  ],
  "_resolved": "https://registry.npmjs.org/commander/-/commander-2.10.0.tgz",
  "_shasum": "e1f5d3245de246d1a5ca04702fa1ad1bd7e405fe",
  "_shrinkwrap": null,
  "_spec": "commander@2",
  "_where": "C:\\Users\\Giuliano\\worldwind\\nasaworldwind\\node\\node_modules\\d3-dsv",
  "author": {
    "name": "TJ Holowaychuk",
    "email": "tj@vision-media.ca"
  },
  "bugs": {
    "url": "https://github.com/tj/commander.js/issues"
  },
  "dependencies": {
    "graceful-readlink": ">= 1.0.0"
  },
  "description": "the complete solution for node.js command-line programs",
  "devDependencies": {
    "should": ">= 0.0.1 <9.0.0",
    "sinon": ">=1.17.1"
  },
  "directories": {},
  "dist": {
    "integrity": "sha512-q/r9trjmuikWDRJNTBHAVnWhuU6w+z80KgBq7j9YDclik5E7X4xi0KnlZBNFA1zOQ+SH/vHMWd2mC9QTOz7GpA==",
    "shasum": "e1f5d3245de246d1a5ca04702fa1ad1bd7e405fe",
    "tarball": "https://registry.npmjs.org/commander/-/commander-2.10.0.tgz"
  },
  "engines": {
    "node": ">= 0.6.x"
  },
  "files": [
    "index.js"
  ],
  "gitHead": "8870675aa189d84014779b53760544a0e614cb40",
  "homepage": "https://github.com/tj/commander.js#readme",
  "keywords": [
    "commander",
    "command",
    "option",
    "parser"
  ],
  "license": "MIT",
  "main": "index",
  "maintainers": [
    {
      "name": "vanesyan",
      "email": "romain.vanesyan@gmail.com"
    },
    {
      "name": "abetomo",
      "email": "abe@enzou.tokyo"
    },
    {
      "name": "somekittens",
      "email": "rkoutnik@gmail.com"
    },
    {
      "name": "zhiyelee",
      "email": "zhiyelee@gmail.com"
    },
    {
      "name": "tjholowaychuk",
      "email": "tj@vision-media.ca"
    }
  ],
  "name": "commander",
  "optionalDependencies": {},
  "readme": "# Commander.js\n\n\n[![Build Status](https://api.travis-ci.org/tj/commander.js.svg?branch=master)](http://travis-ci.org/tj/commander.js)\n[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)\n[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander)\n[![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n  The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander).  \n  [API documentation](http://tj.github.com/commander.js/)\n\n\n## Installation\n\n    $ npm install commander --save\n\n## Option parsing\n\n Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('commander');\n\nprogram\n  .version('0.1.0')\n  .option('-p, --peppers', 'Add peppers')\n  .option('-P, --pineapple', 'Add pineapple')\n  .option('-b, --bbq-sauce', 'Add bbq sauce')\n  .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')\n  .parse(process.argv);\n\nconsole.log('you ordered a pizza with:');\nif (program.peppers) console.log('  - peppers');\nif (program.pineapple) console.log('  - pineapple');\nif (program.bbqSauce) console.log('  - bbq');\nconsole.log('  - %s cheese', program.cheese);\n```\n\n Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as \"--template-engine\" are camel-cased, becoming `program.templateEngine` etc.\n\n\n## Coercion\n\n```js\nfunction range(val) {\n  return val.split('..').map(Number);\n}\n\nfunction list(val) {\n  return val.split(',');\n}\n\nfunction collect(val, memo) {\n  memo.push(val);\n  return memo;\n}\n\nfunction increaseVerbosity(v, total) {\n  return total + 1;\n}\n\nprogram\n  .version('0.1.0')\n  .usage('[options] <file ...>')\n  .option('-i, --integer <n>', 'An integer argument', parseInt)\n  .option('-f, --float <n>', 'A float argument', parseFloat)\n  .option('-r, --range <a>..<b>', 'A range', range)\n  .option('-l, --list <items>', 'A list', list)\n  .option('-o, --optional [value]', 'An optional value')\n  .option('-c, --collect [value]', 'A repeatable value', collect, [])\n  .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)\n  .parse(process.argv);\n\nconsole.log(' int: %j', program.integer);\nconsole.log(' float: %j', program.float);\nconsole.log(' optional: %j', program.optional);\nprogram.range = program.range || [];\nconsole.log(' range: %j..%j', program.range[0], program.range[1]);\nconsole.log(' list: %j', program.list);\nconsole.log(' collect: %j', program.collect);\nconsole.log(' verbosity: %j', program.verbose);\nconsole.log(' args: %j', program.args);\n```\n\n## Regular Expression\n```js\nprogram\n  .version('0.1.0')\n  .option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')\n  .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)\n  .parse(process.argv);\n  \nconsole.log(' size: %j', program.size);\nconsole.log(' drink: %j', program.drink);\n```\n\n## Variadic arguments\n\n The last argument of a command can be variadic, and only the last argument.  To make an argument variadic you have to\n append `...` to the argument name.  Here is an example:\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('commander');\n\nprogram\n  .version('0.1.0')\n  .command('rmdir <dir> [otherDirs...]')\n  .action(function (dir, otherDirs) {\n    console.log('rmdir %s', dir);\n    if (otherDirs) {\n      otherDirs.forEach(function (oDir) {\n        console.log('rmdir %s', oDir);\n      });\n    }\n  });\n\nprogram.parse(process.argv);\n```\n\n An `Array` is used for the value of a variadic argument.  This applies to `program.args` as well as the argument passed\n to your action as demonstrated above.\n\n## Specify the argument syntax\n\n```js\n#!/usr/bin/env node\n\nvar program = require('commander');\n\nprogram\n  .version('0.1.0')\n  .arguments('<cmd> [env]')\n  .action(function (cmd, env) {\n     cmdValue = cmd;\n     envValue = env;\n  });\n\nprogram.parse(process.argv);\n\nif (typeof cmdValue === 'undefined') {\n   console.error('no command given!');\n   process.exit(1);\n}\nconsole.log('command:', cmdValue);\nconsole.log('environment:', envValue || \"no environment given\");\n```\nAngled brackets (e.g. `<cmd>`) indicate required input. Square brackets (e.g. `[env]`) indicate optional input.\n\n## Git-style sub-commands\n\n```js\n// file: ./examples/pm\nvar program = require('commander');\n\nprogram\n  .version('0.1.0')\n  .command('install [name]', 'install one or more packages')\n  .command('search [query]', 'search with optional query')\n  .command('list', 'list packages installed', {isDefault: true})\n  .parse(process.argv);\n```\n\nWhen `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.  \nThe commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.\n\nOptions can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the option from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified.\n\nIf the program is designed to be installed globally, make sure the executables have proper modes, like `755`.\n\n### `--harmony`\n\nYou can enable `--harmony` option in two ways:\n* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version don’t support this pattern.\n* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.\n\n## Automated --help\n\n The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:\n\n```  \n $ ./examples/pizza --help\n\n   Usage: pizza [options]\n\n   An application for pizzas ordering\n\n   Options:\n\n     -h, --help           output usage information\n     -V, --version        output the version number\n     -p, --peppers        Add peppers\n     -P, --pineapple      Add pineapple\n     -b, --bbq            Add bbq sauce\n     -c, --cheese <type>  Add the specified type of cheese [marble]\n     -C, --no-cheese      You do not want any cheese\n\n```\n\n## Custom help\n\n You can display arbitrary `-h, --help` information\n by listening for \"--help\". Commander will automatically\n exit once you are done so that the remainder of your program\n does not execute causing undesired behaviours, for example\n in the following executable \"stuff\" will not output when\n `--help` is used.\n\n```js\n#!/usr/bin/env node\n\n/**\n * Module dependencies.\n */\n\nvar program = require('commander');\n\nprogram\n  .version('0.1.0')\n  .option('-f, --foo', 'enable some foo')\n  .option('-b, --bar', 'enable some bar')\n  .option('-B, --baz', 'enable some baz');\n\n// must be before .parse() since\n// node's emit() is immediate\n\nprogram.on('--help', function(){\n  console.log('  Examples:');\n  console.log('');\n  console.log('    $ custom-help --help');\n  console.log('    $ custom-help -h');\n  console.log('');\n});\n\nprogram.parse(process.argv);\n\nconsole.log('stuff');\n```\n\nYields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:\n\n```\n\nUsage: custom-help [options]\n\nOptions:\n\n  -h, --help     output usage information\n  -V, --version  output the version number\n  -f, --foo      enable some foo\n  -b, --bar      enable some bar\n  -B, --baz      enable some baz\n\nExamples:\n\n  $ custom-help --help\n  $ custom-help -h\n\n```\n\n## .outputHelp(cb)\n\nOutput help information without exiting.\nOptional callback cb allows post-processing of help text before it is displayed.\n\nIf you want to display help by default (e.g. if no command was provided), you can use something like:\n\n```js\nvar program = require('commander');\nvar colors = require('colors');\n\nprogram\n  .version('0.1.0')\n  .command('getstream [url]', 'get stream URL')\n  .parse(process.argv);\n\n  if (!process.argv.slice(2).length) {\n    program.outputHelp(make_red);\n  }\n\nfunction make_red(txt) {\n  return colors.red(txt); //display the help text in red on the console\n}\n```\n\n## .help(cb)\n\n  Output help information and exit immediately.\n  Optional callback cb allows post-processing of help text before it is displayed.\n\n## Examples\n\n```js\nvar program = require('commander');\n\nprogram\n  .version('0.1.0')\n  .option('-C, --chdir <path>', 'change the working directory')\n  .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')\n  .option('-T, --no-tests', 'ignore test hook');\n\nprogram\n  .command('setup [env]')\n  .description('run setup commands for all envs')\n  .option(\"-s, --setup_mode [mode]\", \"Which setup mode to use\")\n  .action(function(env, options){\n    var mode = options.setup_mode || \"normal\";\n    env = env || 'all';\n    console.log('setup for %s env(s) with %s mode', env, mode);\n  });\n\nprogram\n  .command('exec <cmd>')\n  .alias('ex')\n  .description('execute the given remote cmd')\n  .option(\"-e, --exec_mode <mode>\", \"Which exec mode to use\")\n  .action(function(cmd, options){\n    console.log('exec \"%s\" using %s mode', cmd, options.exec_mode);\n  }).on('--help', function() {\n    console.log('  Examples:');\n    console.log();\n    console.log('    $ deploy exec sequential');\n    console.log('    $ deploy exec async');\n    console.log();\n  });\n\nprogram\n  .command('*')\n  .action(function(env){\n    console.log('deploying \"%s\"', env);\n  });\n\nprogram.parse(process.argv);\n```\n\nMore Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.\n\n## License\n\nMIT\n\n",
  "readmeFilename": "Readme.md",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/tj/commander.js.git"
  },
  "scripts": {
    "test": "make test"
  },
  "version": "2.10.0"
}