Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.
/ hadron-cli Public archive

Library allowing you to define and run your own console commands in no time

License

Notifications You must be signed in to change notification settings

brainhubeu/hadron-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hadron-cli

Console commands framework

Library allowing you to define and run your own console commands in no time.

Basic usage

Installation

hadron-cli requires node 8 or newer

NOTE: the library is in early stage of development, and it's still not published to npm!

Creating simple command

// ./commands/mySimpleCommand.js

export const name = 'myApp:mySimpleCommand';

export const description = 'This command does not do much';

export const action = options => {
  console.log('My simple command got following option:', options.foo);
};

export const flags = {
  foo: {
    alias: 'f',
    description: 'Optional option',
  },
};

Adding command to registry

// ./commands.js
export default [
  'mySimpleCommand.js',
];

Running command

$ hadron myApp:mySimpleCommand -f barbaz

And the result will be:

My simple command got following option: barbaz

Getting help

Help will be automagically generated:

$ hadron --help

Usage: hadron <command> [options]

Commands:
  hadron myApp:mySimpleCommand  This command does not do much

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
$ hadron myApp:mySimpleCommand --help

hadron myApp:mySimpleCommand

This command does not do much

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --foo, -f  Optional option

Docs

Roadmap

  • Write tests
  • Add command validation
  • Add custom help

FAQ

Are there good alternatives?

This library depends on yargs which you may want to use directly.

I found a bug! What should I do?

There are at least 3 options:

  1. Add an issue, write test(s) for bug you found, write fix that will make your test(s) pass, submit pull request
  2. Add an issue, write test(s) for bug you found, submit pull request with you test(s)
  3. Add an issue

About

Library allowing you to define and run your own console commands in no time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published