2.0.7 • Published 7 years ago

modern-cli v2.0.7

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

pascaliske/modern-cli

npm GitHub license Travis Greenkeeper badge

Library for class based modern cli scripts.

Write modern node cli scripts using ES6 classes.

Install

$ yarn add modern-cli

Basic Usage

Here are some basic examples for the usage. For more information see the docs.

Using functions

./examples/basic.js:
import { Cli } from 'modern-cli';

new Cli('script', '1.0.1')
    .addCommands([
        {
            name: 'command',
            description: '',
            execute: () => console.log('success')
        }
    ])
    .run();

Now you can use the script in one of the following ways:

$ babel-node ./examples/basic.js command
$ ./examples/basic.js --help

Using a dedicated command class

./examples/basic2.js:
import { Cli } from 'modern-cli';
import MyCommand from './mycommand.js';

new Cli('script')
    .addCommands([
        new MyCommand()
    ])
    .run();
./examples/mycommand.js:
import { Command } from 'modern-cli';

export default class MyCommand extends Command {
    /**
     * Initializes the cli command
     */
    constructor() {
        super('mycommand', 'Some helpful description of "mycommand".');
    }

    async execute() {
        // here comes your code which should be executed by this command
    }
}

Again, you can use the script in one of the following ways:

$ ./examples/basic2.js mycommand
$ ./examples/basic2.js --help

License

MIT © Pascal Iske

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago