2.1.7 • Published 4 years ago

@sapphirecode/console-app v2.1.7

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

@sapphirecode/console-app

version: 2.1.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, // integer and float values
  IntegerOption, // only integer values
  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

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.8.6

4 years ago

1.8.5

4 years ago

1.8.4

4 years ago

1.8.3

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.7.3

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.6.1

4 years ago

1.5.1

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.3.1

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago