A library for easily creating observable CLI tasks with support for commands, arguments, and options.
Go to file
2016-12-18 01:36:19 +01:00
dist added .triggerCommandByName 2016-12-18 01:36:19 +01:00
docs improve typings and docs 2016-09-04 17:32:12 +02:00
test added .triggerCommandByName 2016-12-18 01:36:19 +01:00
ts added .triggerCommandByName 2016-12-18 01:36:19 +01:00
.gitignore update smartcli 2016-09-04 17:23:29 +02:00
.gitlab-ci.yml fix ci 2016-09-04 17:36:07 +02:00
LICENSE Initial commit 2015-10-04 23:06:36 +02:00
npmts.json update dependencies 2016-05-23 04:09:06 +02:00
package.json 1.0.15 2016-11-19 17:41:16 +01:00
README.md improve README 2016-11-19 17:48:56 +01:00
tslint.json implement standardJS 2016-10-15 00:56:02 +02:00

smartcli

nodejs wrapper for CLI related tasks. TypeScript ready.

Availabililty

npm git git docs

Status for master

build status coverage report Dependency Status bitHound Dependencies bitHound Code TypeScript node

Install the package

npm install smartcli --save

Usage

this plugin tries to establish some logic in which CLI tools work.

take the following commandline input:

mytool command argument1 argument2 --option1 -o2 option2Value
  • mytool obviously is the tool (like git)
  • command is the main thing the tool shall do (like commit)
  • argument1 and argument2 are arguments
  • option1 is a longform option you can add (like --message for message)
  • optionValue is the referenced option value (like a commit message)

When there is no command and no option specified the standardTask applied. When there is a option specified but no command, standardTask applies, except when of the options is -v, --version or --help.

import {Smartcli} from "smartcli"
mySmartcli = new Smartcli();
mySmartcli.standardTask()
  .then(argvArg => {
    // do something if program is called without an command
  });

mySmartcli.addCommand({commandname: 'install'})
  .then(argvArg => {
    // do something if program is called with command "install"
  })

mySmartcli.addVersion('1.0.0') // -v and --version options will display the specified version in the terminal

mySmartCli.addHelp({ // is triggered by help command and --help option
  helpText: 'some help text to print' // the helpText to display
})

mySmartcli.startParse() // starts the evaluation and fullfills or rejects promises.

npm