Socket
Socket
Sign inDemoInstall

cac

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cac - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

14

index.js

@@ -90,2 +90,3 @@ 'use strict';

this.cliUsage = (chalk.yellow(this.pkg.name)) + " " + (chalk.grey('[options] [commands]'))
this.examples = []

@@ -140,3 +141,3 @@ this

var optionsTable = table(Object.keys(this.options).map(function (option) { return [
chalk.yellow(prefixedOption(option, this$1.aliasOptions)),
chalk.yellow(prefixedOption(option, this$1.aliasOptions)),
chalk.grey(this$1.options[option].description),

@@ -154,4 +155,8 @@ showDefaultValue(this$1.options[option].defaultValue)

var help = (this.pkg.description ? ("\n" + (this.pkg.description) + "\n") : '') + "\nUsage: " + (this.cliUsage) + "\n\nCommands:\n\n" + (indent(commandsTable, 2)) + "\n\nOptions:\n\n" + (indent(optionsTable, 2)) + "\n"
var examples = this.examples.length > 0 ?
("\nExamples:\n\n" + (indent(this.examples.join('\n'), 2)) + "\n") :
''
var help = (this.pkg.description ? ("\n" + (this.pkg.description) + "\n") : '') + "\nUsage: " + (this.cliUsage) + "\n" + examples + "\nCommands:\n\n" + (indent(commandsTable, 2)) + "\n\nOptions:\n\n" + (indent(optionsTable, 2)) + "\n"
console.log(indent(help, 2))

@@ -201,2 +206,7 @@ process.exit(0)

CAC.prototype.example = function example (text) {
this.examples.push(text)
return this
};
CAC.prototype.string = function string (value) {

@@ -203,0 +213,0 @@ this.string = value

{
"name": "cac",
"version": "2.2.2",
"version": "2.3.0",
"description": "Command & Conquer, the command-line queen.",

@@ -21,2 +21,7 @@ "license": "MIT",

},
"watch": {
"./src": [
"build"
]
},
"files": [

@@ -23,0 +28,0 @@ "index.js"

22

README.md

@@ -30,3 +30,3 @@ # cac [![NPM version](https://img.shields.io/npm/v/cac.svg)](https://npmjs.com/package/cac) [![NPM downloads](https://img.shields.io/npm/dm/cac.svg)](https://npmjs.com/package/cac) [![Build Status](https://img.shields.io/circleci/project/egoist/cac/master.svg)](https://circleci.com/gh/egoist/cac)

<img src="http://ww4.sinaimg.cn/large/a15b4afegw1f79ix3vc2uj20p00akjsj.jpg" width="400" />
<img src="./media/preview-1.jpg" width="400" />

@@ -38,7 +38,7 @@ ### Default commands and options

<img src="http://ww4.sinaimg.cn/large/a15b4afegw1f79k0eifspj20ug0g0mz3.jpg" width="400" />
<img src="./media/preview-2.jpg" width="400" />
## API
## .option(options, description, defaultValue)
### .option(options, description, defaultValue)

@@ -49,3 +49,3 @@ - **options**: `string`, it could be `option` or `option, alias` or `alias, option`, the order does not matter. eg: `.option('install, i')`

## .command(commands, description, fn)
### .command(commands, description, fn)

@@ -58,24 +58,28 @@ - **commands**: `string`, it could be `command` or `command, alias` or `alias, command`, the order does not matter. eg: `.command('clone, c')`. It can also be a wildcard symbol `*`, which means always been triggered if no command was specified by user.

## .usage(text)
### .usage(text)
- **text**: `string`, the cli usage. default is `$bin [options] [commands]`
## .parse(argv)
### .parse(argv)
- **argv**: `array`, default is `process.argv.slice(2)`
## .onError(handleError)
### .onError(handleError)
- **handleError**: `function`, triggered when your program throws an error or was rejected by a Promise call.
## .string(string | array)
### .string(string | array)
a string or array of strings argument names to always treat as strings
## .boolean(boolean | string | array)
### .boolean(boolean | string | array)
a boolean, string or array of strings to always treat as booleans. if true will treat all double hyphenated arguments without equal signs as boolean (e.g. affects --foo, not -f or --foo=bar)
### .example(text)
Add an example command for your command, will be shown in CLI usage.
## License
MIT © [egoist](https://github.com/egoist)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc