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 (commandNameString, commandDescriptionoptString, clioptString) → Options static

Create a new options definition.

Arguments:
  • commandName: String

    Name of a command then executed from a command line

  • commandDescription: String

    Command description for help (-help switch)

  • cli: String

    Command line interpretator

  
      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 (switchNamestring) → 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:

# switchValue (switchNamestring) → 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:

Types

# Option inner

Properties

  • short String

    a short option name

  • long String

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

  • param opt String

    if 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 Boolean

    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