forked from entropitor/dotenv-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli-load.js
executable file
·30 lines (25 loc) · 1.57 KB
/
cli-load.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
const argv = require('minimist')(process.argv.slice(2))
const cli = require('./cli-base')
function printHelp () {
console.log([
'Usage: dotload [--help] [--debug] [-e <path>] [-v <name>=<value>] [-p <variable name>] [-- command]',
' --help print help',
' --debug output the files that would be processed but don\'t actually parse them or run the `command`',
' -e <path> parses the file <path> as a `.env` file and adds the variables to the environment',
' -e <path> multiple -e flags are allowed',
' -v <name>=<value> put variable <name> into environment using value <value>',
' -v <name>=<value> multiple -v flags are allowed',
' -p <variable> print value of <variable> to the console. If you specify this, you do not have to specify a `command`',
' [DOT_ENV] load cascading env variables with [environment] set as [DOT_ENV] environment variable',
' command `command` is the actual command you want to run. Best practice is to precede this command with ` -- `. Everything after `--` is considered to be your command. So any flags will not be parsed by this tool but be passed to your command. If you do not do it, this tool will strip those flags',
'',
' e.g.',
' > export DOT_ENV=development ; dotload -p PORT => 3000',
' > export DOT_ENV=production ; dotload -p PORT => 4000',
'',
' Useful when you want to define a script and run with different environments'
].join('\n'))
}
argv.C = 'DOT_ENV'
cli(argv, printHelp)