This package has been deprecated

Author message:

Not maintained anymore

@absolunet/cli

0.9.1 • Public • Published

@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

Readme

Keywords

Package Sidebar

Install

npm i @absolunet/cli

Weekly Downloads

44

Version

0.9.1

License

MIT

Unpacked Size

14.3 kB

Total Files

4

Last publish

Collaborators

  • valtech_commerce
  • absobot
  • jblandry