Update logo and add run directive

master
Garrett Mills 3 years ago
parent 0d533c5d9d
commit 7cffc2a359
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

@ -0,0 +1,26 @@
import {Directive} from "../Directive"
import {Injectable} from "@extollo/di"
import {Unit} from "@extollo/lib"
import {ErrorWithContext} from "@extollo/util"
import {CommandLineApplication} from "../service"
@Injectable()
export class RunDirective extends Directive {
getDescription(): string {
return 'run the application normally'
}
getKeywords(): string | string[] {
return ['run', 'up']
}
async handle(): Promise<void> {
if ( !CommandLineApplication.getReplacement() ) {
throw new ErrorWithContext(`Cannot run application: no run target specified.`)
}
const unit = <Unit> this.make(CommandLineApplication.getReplacement())
await this.app().startUnit(unit)
await this.app().stopUnit(unit)
}
}

@ -1,3 +1,4 @@
import {DependencyKey} from "@extollo/di"
import {Directive} from "../Directive"
import * as colors from "colors/safe"
import * as repl from 'repl'
@ -25,8 +26,7 @@ export class ShellDirective extends Directive {
async handle(): Promise<void> {
const state: any = {
app: this.app(),
make: this.make,
container: this.container,
make: (target: DependencyKey, ...parameters: any[]) => this.make(target, ...parameters),
}
await new Promise<void>(res => {

@ -35,12 +35,14 @@ export class CommandLine extends Unit {
}
public getASCIILogo() {
return ` ______ _ _ _
| ____| | | | | |
| |__ __ _| |_ ___ | | | ___
| __| \\ \\/ / __/ _ \\| | |/ _ \\
| |____ > <| || (_) | | | (_) |
|______/_/\\_\\\\__\\___/|_|_|\\___/`
return ` _
/ /\\ ______ _ _ _
/ / \\ | ____| | | | | |
/ / /\\ \\ | |__ __ _| |_ ___ | | | ___
/ / /\\ \\ \\ | __| \\ \\/ / __/ _ \\| | |/ _ \\
/ / / \\ \\_\\ | |____ > <| || (_) | | | (_) |
\\/_/ \\/_/ |______/_/\\_\\\\__\\___/|_|_|\\___/
`
}
public registerDirective(directiveClass: Instantiable<Directive>) {

@ -5,6 +5,7 @@ import {UsageDirective} from "../directive/UsageDirective";
import {Directive} from "../Directive";
import {ShellDirective} from "../directive/ShellDirective";
import {TemplateDirective} from "../directive/TemplateDirective";
import {RunDirective} from "../directive/RunDirective";
@Singleton()
export class CommandLineApplication extends Unit {
@ -13,6 +14,10 @@ export class CommandLineApplication extends Unit {
this.replacement = unitClass
}
public static getReplacement() {
return this.replacement
}
@Inject()
protected readonly cli!: CommandLine
@ -25,6 +30,7 @@ export class CommandLineApplication extends Unit {
this.cli.registerDirective(UsageDirective)
this.cli.registerDirective(ShellDirective)
this.cli.registerDirective(TemplateDirective)
this.cli.registerDirective(RunDirective)
const argv = process.argv.slice(2)
const match = this.cli.getDirectives()

Loading…
Cancel
Save