@absolunet/cli
CLI utilities
Last updated 3 months ago by jblandry .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @absolunet/cli 
SYNC missed versions from official npm registry.

@absolunet/cli

npm npm dependencies npms Travis CI Code style ESLint

CLI utilities

Built around meow

Install

$ npm install @absolunet/cli

Usage

const cli = require('@absolunet/cli');

cli.initTasksList('./tasks');

cli.setUsageTasks({

	// Base
	'start': ['start', 'Start project'],
	'stop':  ['stop',  'Stop project'],
	'log':   [`log ${cli.optionalPlaceholder('<sub>')}`, 'Show log for sub', ['sub1', 'sub2']],

	// Options
	'--help':    ['-h, --help',    'Show help'],
	'--version': ['-v, --version', 'Show version']

});

cli.setFullUsage({
	'Base':    ['start', 'stop', 'log'],
	'Options': ['--help', '--version']
});

console.log(cli.fullUsage);
	Test project description

	Usage: testprj <command>

	Base
	start             Start project
	stop              Stop project
	log [<sub>]       Show log for sub [sub1|sub2]

	Options
	-h, --help        Show help
	-v, --version     Show version

	testprj@1.2.3 /usr/local/bin/testprj


init([options])

Build tasks list from js filenames

options.pkgPath

Type: string
Path to package.json folder

options.pkg

Type: object
package.json-like object


API - Tasks

initTasksList(tasksPath)

Build tasks list from js filenames

tasksPath

Required
Type: string
Path to tasks folder


tasksRouter(meowCli)

Require task file specified by CLI

meowCli

Required
Type: object
meow object


tasks

Type: Array
List of tasks



API - Usage

placeholder(name)

Look placeholder
Return string of looked placeholder

name

Required
Type: string
Text to theme


optional(name)

Look optional
Return string of looked optional

name

Required
Type: string
Text to theme


optionalPlaceholder(name)

Look optional placeholder
Return string of looked optional placeholder

name

Required
Type: string
Text to theme


setUsageTasks(commands)

Set tasks usage and autocomplete data

commands

Required
Type: object
Check example for structure


setFullUsage(fullUsage [, options])

Set full usage structure

fullUsage

Required
Type: object
Check example for structure

options.showBin

Type: boolean
Show version and bin location
Default: true


getTaskUsage(task)

Get task usage
Return string of task usage

task

Required
Type: string
Check example for structure


showTaskUsage(meowCli)

Display task usage and quit

meowCli

Required
Type: object
meow object


fullUsage

Type: string
Description and tasks formatted as a user manual



API - Helpers

refuseArguments(meowCli)

Show task usage and quit if CLI call has arguments

meowCli

Required
Type: object
meow object


ow

Type: Object
Instance of local ow


refuseFlags(meowCli)

Show task usage and quit if CLI call has flags

meowCli

Required
Type: object
meow object


refuseFlagsAndArguments(meowCli)

Show task usage and quit if CLI call has arguments or flags

meowCli

Required
Type: object
meow object


validateFlags(meowCli, flag)

Show task usage and quit if CLI call has flags that are not whitelisted and do not validate
Return object of flags values

meowCli

Required
Type: object
meow object

flagValidations

Required
Type: object of flag validators
Whitelisted flags and their ow predicate (use cli.ow to ensure to use the same version)


isRoot()

Check if CLI is run by root user
Return boolean


binName

Type: string
Binary name


rawArguments

Type: string
Space separated arguments from terminal



License

MIT © Absolunet

Current Tags

  • 0.9.1                                ...           latest (3 months ago)

20 Versions

  • 0.9.1                                ...           3 months ago
  • 0.9.0                                ...           a year ago
  • 0.5.2-patch.bin                                ...           a year ago
  • 0.8.0                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.2                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 61
Last Day 0
Last Week 1
Last Month 0
Dependencies (8)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |