namirasoft-node-cli
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -6,3 +6,6 @@ import { Application } from "./Application"; | ||
constructor(app: Application, argv: string[]); | ||
abstract run(): Promise<void>; | ||
protected abstract getError(): Promise<string | null>; | ||
protected abstract exec(): Promise<void>; | ||
run(): Promise<void>; | ||
abstract help(): void; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -9,4 +18,15 @@ exports.BaseCommand = void 0; | ||
} | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let error = yield this.getError(); | ||
if (error == null) | ||
yield this.exec(); | ||
else { | ||
this.app.logger.error(error); | ||
this.help(); | ||
} | ||
}); | ||
} | ||
} | ||
exports.BaseCommand = BaseCommand; | ||
//# sourceMappingURL=BaseCommand.js.map |
@@ -8,4 +8,5 @@ import { Application } from "./Application"; | ||
}); | ||
run(): Promise<void>; | ||
getError(): Promise<"Argument was not provided." | null>; | ||
exec(): Promise<void>; | ||
help(): void; | ||
} |
@@ -19,9 +19,13 @@ "use strict"; | ||
} | ||
run() { | ||
getError() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let name = this.argv[0]; | ||
if (!name || name == "help" || name == "h") { | ||
this.help(); | ||
return; | ||
} | ||
if (!name) | ||
return "Argument was not provided."; | ||
return null; | ||
}); | ||
} | ||
exec() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let name = this.argv[0]; | ||
let Command = this.commands[name]; | ||
@@ -28,0 +32,0 @@ if (Command) { |
@@ -1,4 +0,6 @@ | ||
import { BaseNavigatorCommand } from "./BaseNavigatorCommand"; | ||
export declare class HelpCommand extends BaseNavigatorCommand { | ||
run(): Promise<void>; | ||
import { Application } from "./Application"; | ||
import { BaseFinalCommand } from "./BaseFinalCommand"; | ||
export declare class HelpCommand extends BaseFinalCommand { | ||
constructor(app: Application, argv: string[]); | ||
exec(): Promise<void>; | ||
} |
@@ -13,5 +13,8 @@ "use strict"; | ||
exports.HelpCommand = void 0; | ||
const BaseNavigatorCommand_1 = require("./BaseNavigatorCommand"); | ||
class HelpCommand extends BaseNavigatorCommand_1.BaseNavigatorCommand { | ||
run() { | ||
const BaseFinalCommand_1 = require("./BaseFinalCommand"); | ||
class HelpCommand extends BaseFinalCommand_1.BaseFinalCommand { | ||
constructor(app, argv) { | ||
super(app, argv, [], []); | ||
} | ||
exec() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -18,0 +21,0 @@ this.app.main.help(); |
@@ -1,4 +0,6 @@ | ||
import { BaseCommand } from "./BaseCommand"; | ||
export declare class VersionCommand extends BaseCommand { | ||
run(): Promise<void>; | ||
import { BaseFinalCommand } from "./BaseFinalCommand"; | ||
import { Application } from "./Application"; | ||
export declare class VersionCommand extends BaseFinalCommand { | ||
constructor(app: Application, argv: string[]); | ||
exec(): Promise<void>; | ||
} |
@@ -14,5 +14,8 @@ "use strict"; | ||
const namirasoft_core_1 = require("namirasoft-core"); | ||
const BaseCommand_1 = require("./BaseCommand"); | ||
class VersionCommand extends BaseCommand_1.BaseCommand { | ||
run() { | ||
const BaseFinalCommand_1 = require("./BaseFinalCommand"); | ||
class VersionCommand extends BaseFinalCommand_1.BaseFinalCommand { | ||
constructor(app, argv) { | ||
super(app, argv, [], []); | ||
} | ||
exec() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -19,0 +22,0 @@ let pkg = namirasoft_core_1.PackageService.getMain(); |
{ | ||
"name": "namirasoft-node-cli", | ||
"description": "Namira Software Corporation Node CLI NPM Package", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"main": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
@@ -12,3 +12,16 @@ import { Application } from "./Application"; | ||
} | ||
abstract run(): Promise<void>; | ||
protected abstract getError(): Promise<string | null>; | ||
protected abstract exec(): Promise<void>; | ||
async run(): Promise<void> | ||
{ | ||
let error = await this.getError(); | ||
if (error == null) | ||
await this.exec(); | ||
else | ||
{ | ||
this.app.logger.error(error); | ||
this.help(); | ||
} | ||
} | ||
abstract help(): void; | ||
} |
@@ -12,10 +12,12 @@ import { Application } from "./Application"; | ||
} | ||
override async run() | ||
override async getError() | ||
{ | ||
let name = this.argv[0]; | ||
if (!name || name == "help" || name == "h") | ||
{ | ||
this.help(); | ||
return; | ||
} | ||
if (!name) | ||
return "Argument was not provided."; | ||
return null; | ||
} | ||
override async exec() | ||
{ | ||
let name = this.argv[0]; | ||
let Command = this.commands[name]; | ||
@@ -31,3 +33,3 @@ if (Command) | ||
} | ||
help() | ||
override help() | ||
{ | ||
@@ -34,0 +36,0 @@ this.app.logger.info("List of avaiable commands are here:"); |
@@ -1,9 +0,14 @@ | ||
import { BaseNavigatorCommand } from "./BaseNavigatorCommand"; | ||
import { Application } from "./Application"; | ||
import { BaseFinalCommand } from "./BaseFinalCommand"; | ||
export class HelpCommand extends BaseNavigatorCommand | ||
export class HelpCommand extends BaseFinalCommand | ||
{ | ||
override async run() | ||
constructor(app: Application, argv: string[]) | ||
{ | ||
super(app, argv, [], []); | ||
} | ||
override async exec() | ||
{ | ||
this.app.main.help(); | ||
} | ||
} |
@@ -10,4 +10,8 @@ import { Application } from "./Application"; | ||
{ | ||
super(app, argv, { "version": VersionCommand, "help": HelpCommand, ...commands }); | ||
super(app, argv, { | ||
"version": VersionCommand, | ||
"help": HelpCommand, | ||
...commands | ||
}); | ||
} | ||
} |
import { PackageService } from "namirasoft-core"; | ||
import { BaseCommand } from "./BaseCommand"; | ||
import { BaseFinalCommand } from "./BaseFinalCommand"; | ||
import { Application } from "./Application"; | ||
export class VersionCommand extends BaseCommand | ||
export class VersionCommand extends BaseFinalCommand | ||
{ | ||
override async run() | ||
constructor(app: Application, argv: string[]) | ||
{ | ||
super(app, argv, [], []); | ||
} | ||
override async exec() | ||
{ | ||
let pkg = PackageService.getMain(); | ||
@@ -9,0 +14,0 @@ this.app.logger.info("Name: " + pkg.getName()); |
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
Sorry, the diff of this file is not supported yet
45342
47
925