https://github.com/0x8f701/caporal-loader
https://github.com/0x8f701/caporal-loader
caporal cli
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/0x8f701/caporal-loader
- Owner: 0x8f701
- License: mit
- Created: 2019-01-21T21:52:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-21T22:40:46.000Z (over 6 years ago)
- Last Synced: 2025-02-18T02:38:17.868Z (8 months ago)
- Topics: caporal, cli
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# caporal-loader
A simple loader aims to simplify the development of cli applications using [caporal](https://github.com/mattallty/Caporal.js).
## Installation
```bash
npm i caporal-loader -S# OR
yarn add caporal-loader
```## Usage
```javascript
const caporalLoader = require('caporal-loader');
caporalLoader()
.subcmdsPath('./subcmds')
.version('1.0.0')
.description('demo app')
.parse();
```**AND** put your subcmds in directory 'subcmds', make them use the following format.
```javascript
const alias = 'ALIAS'; // subcmd aliasconst command = {
name: '', // subcmd's name
description: '' // subcmd's description
};const arguments = [
{
var: 'NAME', // name to be used in action. e.g. args.NAME
description: '',
complete: () => Promise.resolve([...])
}
];const options = [
{
var: 'NAME',
description: '',
validator: () => {},
default: '',
required: '',
complete: () => Promise.resolve([...])
}
];const action = (args, opts, log) => {
//
};module.exports = {
alias,
command,
arguments,
options,
action
}
```