Giter VIP home page Giter VIP logo

modern-cli's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.