0.0.4 • Published 2 years ago
@bleed-believer/command v0.0.4
@bleed-believer/command
This is a BleedBeliever module to make command routing from arguments passed by the user through the command console.
Installation
First install the @bleed-believer/core package:
npm i --save @bleed-believer/core
Then, install this package:
npm i --save @bleed-believer/command
Usage
First, you must make a Command
class using the according decorators:
import { Command, CommandMethod } from '@bleed-believer/command';
@Command({
main: [ 'start' ],
title: 'Start command'
})
export class StartCommand {
@CommandMethod()
start(): void {
console.log('Hello World');
}
}
Then, create a module with your commands:
import { CommandRouter } from '@bleed-believer/command';
import { BleedModule } from '@bleed-believer/core';
import { StartCommand } from './start-command';
import { StopCommand } from './stop-command';
@BleedModule({
imports: [
CommandRouter.addToRouter([
StartCommand, // The class created above
StopCommand // Another command class
])
]
})
export class AppRouting {}
Finally, Add your AppRouting
module as a parameter into the BleedBeliever
constructor, and initialize the bleeding process:
import { BleedBeliever } from '@bleed-believer/core';
import { AppRouting } from './app-routing';
const main = new BleedBeliever(AppRouting);
main.bleed();