Yargs command for managing env files.
(Object
= {}
)
options for this function.
Name | Description |
---|---|
options.file string
|
default path to env file for yargs.
|
options.command string
(default 'env' )
|
name of base
<env>
command.
|
options.defaults Object
(default {} )
|
default env object to be used.
|
options.describe string
|
description for base
<env>
command.
|
options.task Object
(default {} )
|
options for
<task>
commands.
|
options.task.command Object
(default 'task' )
|
name of
<task>
command.
|
options.task.key string
(default 'key' )
|
name of optional
[key]
argument.
|
options.task.value string
(default 'value' )
|
name of optional
[value]
argument.
|
options.task.env string
(default 'env' )
|
name of optional
[--env]
argument.
|
options.task.reset Object
(default 'reset' )
|
name of
<task
> command for
reset
.
|
options.task.clear Object
(default 'clear' )
|
name of
<task
> command for
clear
.
|
options.task.view Object
(default 'view' )
|
name of
<task
> command for
view
.
|
options.task.delete Object
(default 'delete' )
|
name of
<task
> command for
delete
.
|
options.task.set Object
(default 'set' )
|
name of
<task
> command for
set
.
|
Object
:
Yargs
Command Module
with the following properties (
out
is the returned Object):
out.command
: the command string in the form of options.command <options.task.command> [options.task.key] [options.task.value] [--options.task.env]
out.describe
: the description string for out.command
out.handler
: the function that manages the env file and returns an argv
Object containing command line arguments// *** DEFAULT ***
var yargs = require('yargs');
// (env) Load command with path to env file
var env = require('yargs-command-env')({file: 'path/to/.env'});
// (yargs) Add command to manage env file
var argv = yargs.command(env).argv;
// *** CUSTOM ***
var yargs = require('yargs');
// (options_command) Setup command options
options = {};
options.file = 'path/to/.env';
options.command = 'env2';
options.defaults = {field: 'value'};
options.describe = 'Description';
// (options_task) Setup task options
options.task = {};
options.task.command = 'task2';
options.task.key = 'key2';
options.task.value = 'value2';
options.task.env = 'env2';
options.task.reset = 'reset2';
options.task.clear = 'clear2';
options.task.view = 'view2';
options.task.delete = 'delete2';
options.task.set = 'set2';
// (env) Load command with options
var env = require('yargs-command-env')(options);
// (yargs) Add command to manage env file
var argv = yargs.command(env).argv;