Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kotborealis/chen
:smiley_cat: Node.JS tool to parse cli arguments, enviroment variables and load configs from .js files
https://github.com/kotborealis/chen
args chen cli config env js nodejs
Last synced: about 2 months ago
JSON representation
:smiley_cat: Node.JS tool to parse cli arguments, enviroment variables and load configs from .js files
- Host: GitHub
- URL: https://github.com/kotborealis/chen
- Owner: kotborealis
- Created: 2017-02-13T11:26:16.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-23T10:58:32.000Z (almost 2 years ago)
- Last Synced: 2024-09-23T13:39:42.359Z (3 months ago)
- Topics: args, chen, cli, config, env, js, nodejs
- Language: JavaScript
- Homepage: https://awooo.ru/
- Size: 184 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
![Cheeen~](./img/chen.png)
# Chen.js :smiley_cat:
:smiley_cat: Node.JS tool to parse cli arguments, enviroment variables and load configs from .js files
## CLI arguments parser
```js
// Called with args:
// --prop 100 --flag -abc input output --type="pdf document" -- "more unnamed args" -not-a-a-flagrequire('chen.js').args();
/**
{
_: ['input', 'output', 'more unnamed args', '-not-a-a-flag'],
prop: 100,
flag: true,
a: true,
b: true,
c: true,
type: 'pdf document',
}
**/
```## Config loader
```js
/**
* Loads `${PWD}/.config.js` by default
*/
const config = require('chen.js').config();
``````js
/**
* Loads `${PWD}/.cfg.js`
*/
const config = require('chen.js').config('.cfg.js');
``````js
/**
* Loads `${PWD}/.config.js`
* Loads `${PWD}/.config.dev.js` and overrides previous config
*/
const config = require('chen.js').config(['.config.js', '.config.dev.js']);
``````js
/**
* Assuming called with CLI args: --config=.config.dev.js
* Loads `${PWD}/.config.js`
* Loads `${PWD}/.config.dev.js` and overrides previous config
*/
const config = require('chen.js').config();
``````js
/**
* Assuming called with CLI args: --config=.config.dev.js --config=.config.dev2.js
* Loads `${PWD}/.config.js`
* Loads `${PWD}/.config.dev.js` and overrides previous config
* Loads `${PWD}/.config.dev2.js` and overrides previous config
*/
const config = require('chen.js').config();
```## Env parser
Loads and parses environment variables and .env files (via dotenv package).
```js
const env = require('chen').env();
```