GithubHelp home page GithubHelp logo

imazzine / cli Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 562 KB

The core module of the "zz" command-line interface. It brings "zz add" and "zz remove" commands to the terminal which allows you to plugged-in/out any other compatible command under "zz" namespace to build your custom CLI toolset.

License: Apache License 2.0

JavaScript 98.37% Dockerfile 1.58% Shell 0.05%
cli-commands cli-framework

cli's Introduction

@imazzine/cli

npm version Build Status Coverage Status NPM Downloads Install Size

The core module of the zz command-line interface. It brings zz add and zz remove commands to the terminal which allows you to plugged-in/out any other compatible command under zz namespace to build your custom CLI toolset.

@imazzine/cli built with the JavaScript and uses the commander.js API under the hood, which means that pluggable commands needs to be implemented with the one of the most popular command-line interface solution for the node.js.

Prerequisites

@imazzine/cli uses ES6 Modules internally, so it depends on node.js v14+. No any other requirements or constraints are provided.

Installation

@imazzine/cli was designed as a globally installed utility. You can perform installation via npm:

$ npm i -g @imazzine/cli

or yarn:

$ yarn global add @imazzine/cli

Pluggable commands interface

As already was mentioned, @imazzine/cli uses commander.js under the hood.

Command, pluggable to the @imazzine/cli -- is a simple JavaScript module (in general just a simple .js file) which exports as a default (in terms of ES6 Modules) valid JavaScript function.

This function will be called with the single parameter -- program, which is an instance of commander.js program interface.

Internally your plugin could perform any operations with the program interface according to the official documentation to configure additional CLI commands.

So, the simplest example could looks like this:

// ~/zz-plugins/tmp.js
export default function(program) {
  program
    .command('tmp')
    .description('tmp')
    .action((subject, command) => {
      console.log('cmd tmp!');
    });
}

Usage

After installation you can run zz help command in you terminal.

$ zz help
zz [options] [command]

Options:
  -V, --version            output the version number
  -h, --help               display help for command

Commands:
  add <subject> <path>     add specified <subject> (either "command" or "project") to @imazzine/cli
  remove <subject> <path>  remove specified <subject> (either "command" or "project") from @imazzine/cli
  help [command]           display help for command

To add tmp command from the example above, you should run:

$ zz add command ~/zz-plugins/tmp.js

zz add command will resolve absolute path and locally and globally installed node modules. So, your plugins could be distributed in a different ways.

After your command was plugged-in, you are able to use it:

$ zz tmp
cmd tmp!

To remove previously added command you need to run:

$ zz remove command ~/zz-plugins/tmp.js

Contributing

@imazzine/cli is mostly driven by the maintainers and definitely needed community contributions. Any contribution helps us keeping this project running.

Please read the contributing guidelines.

cli's People

Contributors

buntarb avatar imazzine avatar

Watchers

 avatar

cli's Issues

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.