easy-commander

This is a framework that allows you to create clis quickly and easily, based on commander.

Usage no npm install needed!

<script type="module">
  import easyCommander from 'https://cdn.skypack.dev/easy-commander';
</script>

README

Easy Commander

easy-commander is a framework that allows you to create clis quickly and easily, based on commander.

Installation

npm i --SAVE easy-commander or yarn add easy-commander

Quick Start

  1. import {cmdMaker, ICmd} from "easy-commander";.
  2. Create your <Cmd_Blob> of interface ICmd.
  3. Using method cmdMaker.append({<Cmd_Name> : <Cmd_Blob> }) to load it.
  4. If you would like to add more, there are 3 ways:
    1. add more <Cmd_Blob> in the input structure cmdMaker.append({ a: blob1, b: blob2, ... })
    2. pipe the method append cmdMaker.append({ a: blob1 }).append({ b: blob2 })
    3. both
  5. Finally, call cmdMaker.start()

Advanced Usages

  • get commander

    cmdMaker.commander

  • to apply custom setting of command

    cmdMaker.custom(cmd => { ... })

  • set version when start

    cmdMaker.start({ version: "0.1.0", ... })

  • set fallback method when start

    cmdMaker.start({ cbFallback: ()=> { /** do sth. */ }, ... })

Usage Examples