Parse a command line options & environment variables and create a configuration object.
const cmdLineOpt = require('@unitybase/base').options
const argv = require('@unitybase/base').argv
let paramsDescription = 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'
})
let passedOptions = paramsDescription.parseVerbose({}, true)
Classes
Methods
# describe (commandName: String, commandDescriptionopt: String, cliopt: String) → Options static
Create a new options definition.
Arguments:
const cmdLineOpt = require('cmd/options')
let paramsDescription = 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'
})
let options = paramsDescription.parseVerbose({}, true);
# switchIndex (switchName: string) → 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
Return:
switch index if found or -1 otherwise
Arguments:
switchName
: string
# switchValue (switchName: string) → String | undefined 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
Return:
switch value or undefined
in case switch not found or switch not have value
Arguments:
switchName
: string
Types
# Option inner
Properties
short
: Stringa short option name
long
: Stringa long option name. This name are used in
parse
resultparam
opt : Stringif parameter has a value - help string for a parameter name
-short param
defaultValue
opt : *a default value for a property. For a string properties what allow empty value set it to
*
searchInEnv
opt = false : Booleanif property do not passed as a cmd line switch then perform search of
UB_
+long.toUpperCase() in environment variableshelp
: Stringa help string for a
usage()
call