diff --git a/package.json b/package.json index f081e4e..09334f1 100644 --- a/package.json +++ b/package.json @@ -1,42 +1,42 @@ { - "name": "clime", - "version": "0.4.1", - "description": "The command-line interface framework for TypeScript.", - "main": "bld/index.js", - "typings": "bld/index.d.ts", - "scripts": { - "test": "mocha", - "build": "tsc" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vilic/clime.git" - }, - "keywords": [ - "typescript", - "command", - "cli", - "commander", - "commander.js" - ], - "author": "vilicvane", - "license": "MIT", - "bugs": { - "url": "https://github.com/vilic/clime/issues" - }, - "homepage": "https://github.com/vilic/clime#readme", - "dependencies": { - "chalk": "^1.1.1", - "extendable-error": "^0.1.2", - "hyphenate": "^0.2.1", - "reflect-metadata": "^0.1.3", - "villa": "^0.2.0" - }, - "devDependencies": { - "chai": "^3.5.0", - "chai-as-promised": "^5.3.0", - "mocha": "^3.0.2", - "source-map-support": "^0.4.0", - "typescript": "^2.0.2" - } + "name": "clime", + "version": "0.4.2", + "description": "The command-line interface framework for TypeScript.", + "main": "bld/index.js", + "typings": "bld/index.d.ts", + "scripts": { + "test": "mocha", + "build": "tsc" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/vilic/clime.git" + }, + "keywords": [ + "typescript", + "command", + "cli", + "commander", + "commander.js" + ], + "author": "vilicvane", + "license": "MIT", + "bugs": { + "url": "https://github.com/vilic/clime/issues" + }, + "homepage": "https://github.com/vilic/clime#readme", + "dependencies": { + "chalk": "^1.1.1", + "extendable-error": "^0.1.2", + "hyphenate": "^0.2.1", + "reflect-metadata": "^0.1.3", + "villa": "^0.2.0" + }, + "devDependencies": { + "chai": "^3.5.0", + "chai-as-promised": "^5.3.0", + "mocha": "^3.0.2", + "source-map-support": "^0.4.0", + "typescript": "^2.0.3" + } } diff --git a/src/core/command/param.ts b/src/core/command/param.ts index aff9a1a..8a43d10 100644 --- a/src/core/command/param.ts +++ b/src/core/command/param.ts @@ -1,5 +1,7 @@ import * as assert from 'assert'; +import hyphenate from 'hyphenate'; + import { Command, GeneralValidator @@ -63,8 +65,7 @@ export function param( description }: ParamOptions = {} ) { - // TODO: name: 'execute' - return (target: Command, name: string, index: number) => { + return (target: Command, name: 'execute', index: number) => { assert.equal(name, 'execute'); let constructor = target.constructor as typeof Command; @@ -80,7 +81,8 @@ export function param( type = type || Reflect.getMetadata('design:paramtypes', target, 'execute')[index] as Clime.Constructor; - paramName = paramName || Reflection.getFunctionParameterName(target.execute, index); + paramName = paramName || + hyphenate(Reflection.getFunctionParameterName(target.execute, index), { lowerCase: true }); if (!validators) { validators = validator ? [validator] : []; diff --git a/src/core/command/params.ts b/src/core/command/params.ts index 2aa15bc..d714709 100644 --- a/src/core/command/params.ts +++ b/src/core/command/params.ts @@ -1,5 +1,7 @@ import * as assert from 'assert'; +import hyphenate from 'hyphenate'; + import { Command, GeneralValidator @@ -59,8 +61,7 @@ export function params( description }: ParamsOptions ) { - // TODO: name: 'execute' - return (target: Command, name: string, index: number) => { + return (target: Command, name: 'execute', index: number) => { assert.equal(name, 'execute'); let constructor = target.constructor as typeof Command; @@ -74,7 +75,8 @@ export function params( type = type || Reflect.getMetadata('design:paramtypes', target, 'execute')[index] as Clime.Constructor; - paramName = paramName || Reflection.getFunctionParameterName(target.execute, index); + paramName = paramName || + hyphenate(Reflection.getFunctionParameterName(target.execute, index), { lowerCase: true }); if (!validators) { validators = validator ? [validator] : [];