0.9.1 • Published 5 years ago

@absolunet/cli v0.9.1

Weekly downloads
61
License
MIT
Repository
github
Last release
5 years ago

@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

0.9.1

5 years ago

0.9.0

6 years ago

0.5.2-patch.bin

6 years ago

0.8.0

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago