Install the package using NPM or any other package manager of your choice.
npm install @formidablejs/cli-loader @formidablejs/console
npm install --save-dev ts-node typescript
Import the loader
function from @formidablejs/cli-loader
and Application
class from @formidablejs/console
. Pass the Application
class to the loader
function and call the run
method on the returned instance.
Create a script named run
under the bin
directory:
#!/usr/bin/env node
const { loader } = require('@formidablejs/cli-loader')
const { Application } = require('@formidablejs/console')
const path = require('path')
const project = path.join(__dirname, '..', 'tsconfig.json')
require('ts-node').register({project})
loader(Application, {
development: true,
root: path.join(__dirname, '...')
}).run()
Create a class named HelloCommand.ts
under the src/Commands
directory:
const { Command } = from '@formidablejs/console'
export default class HelloCommand extends Command {
get signature(): string {
return 'hello'
}
get description(): string {
return 'Say hello to the world'
}
async handle(): Promise<void> {
this.info('Hello world!')
}
}
chmod +x ./bin/run
./bin/run hello
- Add tests
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.