Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Formidable Console CLI Loader

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages