@anycli/command
Advanced tools
Comparing version 1.2.8 to 1.2.9
@@ -0,1 +1,9 @@ | ||
<a name="1.2.9"></a> | ||
## [1.2.9](https://github.com/anycli/command/compare/ce490223d1d5a23619712330b1919965d3d2e143...v1.2.9) (2018-02-06) | ||
### Bug Fixes | ||
* use [@anycli](https://github.com/anycli)/errors ([b9424dc](https://github.com/anycli/command/commit/b9424dc)) | ||
<a name="1.2.8"></a> | ||
@@ -2,0 +10,0 @@ ## [1.2.8](https://github.com/anycli/command/compare/dd18e9c08ece41f3cbb04b21080a52ffa102cadf...v1.2.8) (2018-02-05) |
@@ -39,3 +39,8 @@ import * as Config from '@anycli/config'; | ||
exit(code?: number): void; | ||
log(s?: string | undefined): void; | ||
warn(input: string | Error): void; | ||
error(input: string | Error, options?: { | ||
code?: string; | ||
exit?: number; | ||
}): void; | ||
log(message?: any): void; | ||
/** | ||
@@ -42,0 +47,0 @@ * actual command run code goes here |
@@ -6,4 +6,5 @@ "use strict"; | ||
const Config = require("@anycli/config"); | ||
const Errors = require("@anycli/errors"); | ||
const util_1 = require("util"); | ||
const flags = require("./flags"); | ||
const util_1 = require("./util"); | ||
class Command { | ||
@@ -38,15 +39,21 @@ constructor(argv, options) { | ||
} | ||
exit(code) { throw new Config.ExitError(code || 0); } | ||
log(s) { | ||
process.stdout.write((s || '') + '\n'); | ||
exit(code = 0) { Errors.exit(code); } | ||
warn(input) { Errors.warn(input); } | ||
error(input, options = {}) { | ||
Errors.error(input, options); | ||
} | ||
log(message = '') { | ||
message = typeof message === 'string' ? message : util_1.inspect(message); | ||
process.stdout.write(message + '\n'); | ||
} | ||
async init() { | ||
this.debug('init version: %s argv: %o', this.ctor._base, this.argv); | ||
global['cli-ux'] = global['cli-ux'] || {}; | ||
global['cli-ux'].debug = global['cli-ux'].debug || !!this.config.debug; | ||
global['cli-ux'].errlog = global['cli-ux'].errlog || this.config.errlog; | ||
global['cli-ux'].context = global['cli-ux'].context || { | ||
command: util_1.compact([this.id, ...this.argv]).join(' '), | ||
version: this.config.userAgent, | ||
}; | ||
if (this.config.debug) | ||
Errors.config.debug = true; | ||
if (this.config.errlog) | ||
Errors.config.errlog = this.config.errlog; | ||
// global['cli-ux'].context = global['cli-ux'].context || { | ||
// command: compact([this.id, ...this.argv]).join(' '), | ||
// version: this.config.userAgent, | ||
// } | ||
global['http-call'] = global['http-call'] || {}; | ||
@@ -53,0 +60,0 @@ global['http-call'].userAgent = this.config.userAgent; |
@@ -9,3 +9,3 @@ "use strict"; | ||
function option(options) { | ||
return build(Object.assign({ optionType: 'custom' }, options))(); | ||
return build(options)(); | ||
} | ||
@@ -12,0 +12,0 @@ exports.option = option; |
{ | ||
"name": "@anycli/command", | ||
"description": "anycli base command", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -16,10 +16,11 @@ "bugs": "https://github.com/anycli/command/issues", | ||
"dependencies": { | ||
"@anycli/parser": "^3.2.4" | ||
"@anycli/parser": "^3.2.5" | ||
}, | ||
"devDependencies": { | ||
"@anycli/config": "^1.3.2", | ||
"@anycli/config": "^1.3.9", | ||
"@anycli/errors": "^0.2.0", | ||
"@anycli/plugin-help": "^0.6.3", | ||
"@anycli/plugin-not-found": "^0.1.16", | ||
"@anycli/plugin-plugins": "^0.2.12", | ||
"@anycli/tslint": "^0.2.5", | ||
"@anycli/tslint": "^0.2.6", | ||
"@types/chai": "^4.1.2", | ||
@@ -26,0 +27,0 @@ "@types/mocha": "^2.2.48", |
34928
15
13
Updated@anycli/parser@^3.2.5