CLI utilities
Built around meow
$ npm install @absolunet/cli
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
[email protected] /usr/local/bin/testprj
Build tasks list from js filenames
Type: string
Path to package.json
folder
Type: object
package.json
-like object
Build tasks list from js filenames
Required
Type: string
Path to tasks folder
Require task file specified by CLI
Required
Type: object
meow object
Type: Array
List of tasks
Look placeholder
Return string
of looked placeholder
Required
Type: string
Text to theme
Look optional
Return string
of looked optional
Required
Type: string
Text to theme
Look optional placeholder
Return string
of looked optional placeholder
Required
Type: string
Text to theme
Set tasks usage and autocomplete data
Required
Type: object
Check example for structure
Set full usage structure
Required
Type: object
Check example for structure
Type: boolean
Show version and bin location
Default: true
Get task usage
Return string
of task usage
Required
Type: string
Check example for structure
Display task usage and quit
Required
Type: object
meow object
Type: string
Description and tasks formatted as a user manual
Show task usage and quit if CLI call has arguments
Required
Type: object
meow object
Type: Object
Instance of local ow
Show task usage and quit if CLI call has flags
Required
Type: object
meow object
Show task usage and quit if CLI call has arguments or flags
Required
Type: object
meow object
Show task usage and quit if CLI call has flags that are not whitelisted and do not validate
Return object
of flags values
Required
Type: object
meow object
Required
Type: object
of flag validators
Whitelisted flags and their ow
predicate (use cli.ow
to ensure to use the same version)
Check if CLI is run by root user
Return boolean
Type: string
Binary name
Type: string
Space separated arguments from terminal
MIT © Absolunet