Skip to content

cli::addFlag

addFlag(parser: CliParser, flag: Dictionary)

ParameterTypeDescription
parserCliParserThe parser to add it to
flagDictionaryA dictionary such as the one in the example below

Adds a flag to the given parser.

Returns

(*) The parser that was given.

Example

elk
parser | cli::addFlag({
     "identifier": "test-flag",  # Identifier used to later get the value of the flag (default: nil)
     "short": "t",               # A short version of the flag (a single letter) (default: nil)
     "long": "test-flag",        # A long version of the flag (default: nil)
     "description": "Test flag", # A description of the flag (default: nil)
     "format": "hh:mm",          # An example of how to format the value given to the flag (default: nil)
     "required": true,           # Whether or not the flag is required (default: false)
 })

 # Default values for the flag object
 {
     "identifier": nil, # Identifier used to later get the value of the flag
     "short": nil, # A short version of the flag (a single letter)
     "long": nil, # A long version of the flag
     "description": nil, # A description of the flag
     "format": nil, # An example of how to format the value given to the flag
     "required": false, # Whether or not the flag is required
     "valueKind": "none", # "none", "path", "directory" or "text"
     "completionHandler": nil, # A function used for custom completions
     "allowCustomCompletionHints": false, # Whether or not hints should be displayed for custom completions
 }
parser | cli::addFlag({
     "identifier": "test-flag",  # Identifier used to later get the value of the flag (default: nil)
     "short": "t",               # A short version of the flag (a single letter) (default: nil)
     "long": "test-flag",        # A long version of the flag (default: nil)
     "description": "Test flag", # A description of the flag (default: nil)
     "format": "hh:mm",          # An example of how to format the value given to the flag (default: nil)
     "required": true,           # Whether or not the flag is required (default: false)
 })

 # Default values for the flag object
 {
     "identifier": nil, # Identifier used to later get the value of the flag
     "short": nil, # A short version of the flag (a single letter)
     "long": nil, # A long version of the flag
     "description": nil, # A description of the flag
     "format": nil, # An example of how to format the value given to the flag
     "required": false, # Whether or not the flag is required
     "valueKind": "none", # "none", "path", "directory" or "text"
     "completionHandler": nil, # A function used for custom completions
     "allowCustomCompletionHints": false, # Whether or not hints should be displayed for custom completions
 }