@mudah-cli/core
v0.9.4
Published
Mudah application kernel: service providers, two-phase boot, events, and discovery.
Maintainers
Readme
@mudah-cli/core
The Mudah application kernel: service providers, two-phase boot, events, plugins, and discovery.
Part of Mudah — an ergonomic, animation-rich CLI
framework. Application extends the IoC Container.
Install
npm install @mudah-cli/coreUsage
import { Application, ServiceProvider, loadManifest } from '@mudah-cli/core';
const app = new Application(process.cwd(), loadManifest(process.cwd()));
class MetricsProvider extends ServiceProvider {
register(): void {
this.app.singleton('metrics', () => new Map<string, number>());
}
boot(): void {
this.app.events().on('command.after', ({ command, durationMs }) => {
// record timings
});
}
}
await app.boot();Two-phase boot runs every register() first, then every boot(), so boot() can depend on
anything any provider registered. Both hooks are async-first. registerLazy(Provider, { commands })
defers expensive providers until a matching command runs.
