Timo Hocker
551b5c89a7
update-scanner: automatic update
@sapphirecode/eslint-config-ts: 1.1.13 ==> 1.1.14 minor @sapphirecode/modelling: 1.1.3 ==> 1.1.4 minor @sapphirecode/utilities: 1.4.3 ==> 1.4.4 minor eslint: 7.2.0 ==> 7.3.0 minor
@sapphirecode/console-app
version: 2.0.x
read parameters from env, config files, console args or interactively
Installation
npm:
npm i --save @sapphirecode/console-app
yarn:
yarn add @sapphirecode/console-app
Usage
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');
const input = await new BooleanOption({
name: 'foo', // option name used in configs and console arguments
// optional settings:
default: false, // default value
sources: {
configs: [], // config files to read from. none by default
interactive: true, // use interactive prompts
console: true // read from console arguments
// environment is always on if the 'env' option below is specified
},
alias: 'f', // shorthand console argument name
env: 'foo_env', // name of the environment variable to read from
message: 'input foo', // message to display in interactive prompt
error: 'failed to read foo', // message to display when input was invalid
error_callback: (opt, val, err)=>{...}, // function to call when an option value could not be read
exit_on_interrupt: true, // exit program when user cancels the interactive prompt
}).parse();
config files can import other config files with #include. example:
#include base.json
{
"foo": "bar"
}
config files are parsed using hjson
License
MIT © Timo Hocker timo@scode.ovh
Description
Languages
TypeScript
96.5%
JavaScript
3.5%