clipanion
Advanced tools
Comparing version 2.4.4 to 2.5.0
@@ -619,3 +619,4 @@ /// <reference types="node" /> | ||
static String(descriptor?: { | ||
required: boolean; | ||
required?: boolean; | ||
name?: string; | ||
}): PropertyDecorator; | ||
@@ -670,2 +671,8 @@ /** | ||
abstract execute(): Promise<number | void>; | ||
/** | ||
* Standard error handler which will simply rethrow the error. Can be used to add custom logic to handle errors | ||
* from the command or simply return the parent class error handling. | ||
* @param error | ||
*/ | ||
catch(error: any): Promise<void>; | ||
validateAndExecute(): Promise<number>; | ||
@@ -672,0 +679,0 @@ /** |
@@ -88,3 +88,3 @@ 'use strict'; | ||
} | ||
static String(descriptor = { required: true }, { tolerateBoolean = false, hidden = false } = {}) { | ||
static String(descriptor = {}, { tolerateBoolean = false, hidden = false } = {}) { | ||
return (prototype, propertyName) => { | ||
@@ -109,3 +109,4 @@ if (typeof descriptor === `string`) { | ||
this.registerDefinition(prototype, command => { | ||
command.addPositional({ name: propertyName, required: descriptor.required }); | ||
var _a; | ||
command.addPositional({ name: (_a = descriptor.name) !== null && _a !== void 0 ? _a : propertyName, required: descriptor.required !== false }); | ||
}); | ||
@@ -182,2 +183,10 @@ this.registerTransformer(prototype, (state, command) => { | ||
} | ||
/** | ||
* Standard error handler which will simply rethrow the error. Can be used to add custom logic to handle errors | ||
* from the command or simply return the parent class error handling. | ||
* @param error | ||
*/ | ||
async catch(error) { | ||
throw error; | ||
} | ||
async validateAndExecute() { | ||
@@ -1229,3 +1238,3 @@ const commandClass = this.constructor; | ||
try { | ||
exitCode = await command.validateAndExecute(); | ||
exitCode = await command.validateAndExecute().catch(error => command.catch(error).then(() => 0)); | ||
} | ||
@@ -1232,0 +1241,0 @@ catch (error) { |
{ | ||
"name": "clipanion", | ||
"version": "2.4.4", | ||
"version": "2.5.0", | ||
"main": "lib/index", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -270,3 +270,3 @@ # <img src="./logo.svg" height="25" /> Clipanion | ||
class RunCommand extends Command { | ||
@Command.Boolean('--arg') | ||
@Command.Array('--arg') | ||
public values: string[]; | ||
@@ -273,0 +273,0 @@ // ... |
Sorry, the diff of this file is not supported yet
160216
3559