npm.io
0.0.7 • Published 6 years ago

@karcass/cli-service

Licence
MIT
Version
0.0.7
Deps
1
Size
10 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

@karcass/cli-service

CLI service for karcass skeleton which helps to build simple CLI interfaces

Installation

npm install @karcass/cli-service

Usage

With this code in example.ts:

import { CliService, AbstractConsoleCommand } from '@karcass/cli-service'

const cliService = new CliService()

class SomeCommand extends AbstractConsoleCommand {
    public static meta = { name: 'do:some', description: 'Does some action' }
    public async execute() {
        console.log('It\'s just work!')
    }
}

cliService.run()

Executing  ts-node example.ts  will print:

=== Available commands: ===
  --help   Show this help
  do:some  Does some action

And executing of  ts-node example.js do:some  will print:

It's just work!

Also you can turn off default --help command behaviour by turning off corresponding setting:

const cliService = new CliService({ useDefaultHelpCommand: false })

Keywords