2020-05-15 16:53:45 +02:00
|
|
|
# @sapphirecode/console-app
|
|
|
|
|
2020-05-28 09:20:53 +02:00
|
|
|
version: 1.8.x
|
2020-05-15 16:53:45 +02:00
|
|
|
|
|
|
|
read parameters from env, console args or interactively
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
npm:
|
|
|
|
|
|
|
|
> npm i --save @sapphirecode/console-app
|
|
|
|
|
|
|
|
yarn:
|
|
|
|
|
|
|
|
> yarn add @sapphirecode/console-app
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2020-06-10 22:44:54 +02:00
|
|
|
const {
|
|
|
|
ArrayOption, // arrays made out of numbers, strings and booleans
|
|
|
|
BooleanOption,
|
|
|
|
FileOption, // paths that exist and are a file
|
|
|
|
FolderOption, // paths that exist and are a folder
|
|
|
|
NumberOption,
|
|
|
|
PathOption, // paths that exist in the file system
|
|
|
|
StringOption,
|
|
|
|
} = require('@sapphirecode/console-app');
|
2020-05-15 16:53:45 +02:00
|
|
|
```
|
|
|
|
|
2020-06-10 22:44:54 +02:00
|
|
|
####################################
|
2020-05-15 16:53:45 +02:00
|
|
|
|
2020-06-10 22:44:54 +02:00
|
|
|
configs: ['json files to search for options'],
|
|
|
|
exit_on_interrupt: true, // exit program when user cancels prompt
|
|
|
|
error_callback: (opt, val, err)=>{...} // function to call when an option value could not be read
|
2020-05-15 16:53:45 +02:00
|
|
|
|
2020-06-10 22:44:54 +02:00
|
|
|
the parameter sources specifies which sources should be used. It reads from all,
|
|
|
|
except config files by default
|
2020-05-15 16:53:45 +02:00
|
|
|
|
2020-05-27 09:55:52 +02:00
|
|
|
config files can import other config files with #include. example:
|
|
|
|
|
|
|
|
```json
|
|
|
|
#include base.json
|
|
|
|
{
|
|
|
|
"foo": "bar"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-05-27 17:39:32 +02:00
|
|
|
config files are parsed using [hjson](https://github.com/hjson/hjson-js)
|
|
|
|
|
2020-05-15 16:53:45 +02:00
|
|
|
## License
|
|
|
|
|
|
|
|
MIT © Timo Hocker <timo@scode.ovh>
|