Comparing version 0.3.0 to 0.4.0
@@ -0,1 +1,2 @@ | ||
import * as inversify_lib_interfaces_interfaces from 'inversify/lib/interfaces/interfaces'; | ||
import { Container } from 'inversify'; | ||
@@ -28,3 +29,3 @@ import { Argv as Argv$1 } from 'yargs'; | ||
constructor({ container, yargs }?: CLIOptions); | ||
register(...commands: CommandStatic[]): this; | ||
register<T extends CommandStatic>(command: T): inversify_lib_interfaces_interfaces.interfaces.BindingWhenOnSyntax<T>; | ||
run(processArgs: string[]): Promise<number>; | ||
@@ -31,0 +32,0 @@ private init; |
@@ -125,2 +125,14 @@ "use strict"; | ||
// src/error.ts | ||
var CLIError = class extends Error { | ||
static { | ||
__name(this, "CLIError"); | ||
} | ||
exitCode; | ||
constructor(message, exitCode) { | ||
super(message); | ||
this.exitCode = exitCode; | ||
} | ||
}; | ||
// src/cli.ts | ||
@@ -138,7 +150,4 @@ var CLI = class _CLI { | ||
} | ||
register(...commands) { | ||
for (const Command2 of commands) { | ||
this.container.bind(Command).toConstantValue(Command2); | ||
} | ||
return this; | ||
register(command) { | ||
return this.container.bind(Command).toConstantValue(command); | ||
} | ||
@@ -174,5 +183,15 @@ async run(processArgs) { | ||
container.bind(Command2).toSelf(); | ||
const stderr = await container.getAsync(Stderr); | ||
const command = await container.getAsync(Command2); | ||
const commandResult = await command.execute(); | ||
args["$?"] = commandResult; | ||
try { | ||
args["$?"] = await command.execute(); | ||
} catch (error) { | ||
if (error instanceof CLIError) { | ||
args["$?"] = error.exitCode ?? 1; | ||
stderr.write(error.message); | ||
stderr.write("\n"); | ||
return; | ||
} | ||
throw error; | ||
} | ||
}); | ||
@@ -179,0 +198,0 @@ this.isInit = true; |
{ | ||
"name": "sgray", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"author": "cumul <gg6123@naver.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37784
406