UNPKG

stackpress

Version:

Incept is a content management framework.

38 lines (37 loc) 1.28 kB
import Terminal from '@stackpress/lib/Terminal'; export default class StackpressTerminal extends Terminal { server; verbose; config; get brand() { return this.control.brand; } get cwd() { return this.server.loader.cwd; } constructor(args, server) { super(args); this.server = server; this.verbose = this.expect(['verbose', 'v'], false); this.config = this.expect(['bootstrap', 'b'], null); this.server.register('cli', this); this._control.brand = this.server.config.path('cli.label', ''); } async bootstrap() { await this.server.bootstrap(); await this.server.resolve('config'); await this.server.resolve('listen'); await this.server.resolve('route'); return this; } async run() { const request = this.server.request({ data: this.data }); const response = this.server.response(); const status = await this.server.emit(this.command, request, response); const verbose = this.expect(['verbose', 'v'], false); if (status.code === 404 && this.command !== 'serve' && verbose) { this._control.error(`Command "${this.command}" not found.`); } return status; } }