@formidablejs/cli-loader
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

CLI Loader

Installation

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

Usage

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.

Initialize the application

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()

Example command

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!')
    }
}

Run the command

chmod +x ./bin/run
./bin/run hello

Todo

  • [ ] Add tests

Security

If you discover any security related issues, please email donaldpakkies@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i @formidablejs/cli-loader

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

10.9 kB

Total Files

18

Last publish

Collaborators

  • donaldpakkies