cmd/options

Parse a command line options & environment variables and create a configuration object.

     var
        cmdLineOpt = require('cmd/options'),
        argv = require('cmd/argv');

     var opts = cmdLineOpt.describe('cmd/generateDDL', 'Check database structure for application domain. Generate DDL (both create and alter) if need and optionally run it')
        .add(argv.establishConnectionFromCmdLineAttributes._cmdLineParams)
        .add({short: 'm',  long: 'models', param: 'modelsList', defaultValue: '*',  help: 'Comma separated model names for DDL generation. If -e specified this options is ignored'})
        .add({short: 'e',  long: 'entities', param: 'entitiesList', defaultValue: '*',  help: 'Comma separated entity names list for DDL generation'})
        .add({short: 'out',  long: 'out', param: 'outputPath', defaultValue: process.cwd(),  help: 'Folder to output generated DDLs (one file per connection)'})
        .add({short: 'autorun',  long: 'autorun', defaultValue: false,  help: 'execute DDL statement after generation. BE CAREFUL! DO NOT USE ON PRODUCTION'});
     options = opts.parseVerbose({}, true);
Author:
  • pavel.mash

Classes

Options

Methods

describe(commandName, commandDescription)Options static

Create a new options definition.
Arguments:
  1. commandName (String)  Name of a command then executed from a command line
  2. commandDescription (String)  Command description for help (-help switch)
Example
var cmdLineOpt = require('cmd/options');
 var opts = cmdLineOpt.describe('cmd/createStore',
        'Create internal store structure (folders) for specifies FileSystem store'
     )
     .add({short: 'cfg',  long: 'cfg', param: 'serverConfig', defaultValue: 'ubConfig.json',  help: 'Server config'})
     .add({short: 'store',  long: 'store', param: 'storesList', defaultValue: '*',  help: 'Comma separated blob stores list'});
 options = opts.parseVerbose({}, true);

switchIndex(switchName)Number static

Determines whether a switchName was passed as a command-line argument to the application Switch may be specified in the following ways on the command line: -switchName or /switchName
Arguments:
  1. switchName

switchValue(switchName)String static

Determines whether a switchName was passed as a command-line argument to the application and have VALUE Switch values may be specified in the following ways on the command line: -switchName Value or /switchName Value
Arguments:
  1. switchName

Type Definitions

Option

Properties:
Name Type Attributes Default Description
short String

a short option name

long String

a long option name. This name are used in parse result

param String <optional>

if parameter has a value - help string for a parameter name -short param

defaultValue * <optional>

a default value for a property. For a string properties what allow empty value set it to *

searchInEnv Boolean <optional>
false

if property do not passed as a cmd line switch then perform search of UB_+long.toUpperCase() in environment variables

help String

a help string for a usage() call