# Argument

Specify positional arguments (required or optional) used by your script.

The argument's value will be available to you as ${args[name]} in your bash function.

bashly.yml
args:
  - name: user
    help: AWS Username.
    required: true

  - name: role
    help: User role.
    default: admin
    allowed:
      - admin
      - guest

  - name: key
    help: Path to SSH key.
    validate: file_exists

# Basic Options

# name

String Required

The name of the argument. Use lowercase letters, since it serves multiple purposes:

  • It will be capitalized in the help text.
  • It will be used as the hash key in the ${args[...]} associative bash array.

# help

String

The message to display when using --help. Can have multiple lines.

# Common Options

# default

String

The value to use in case it is not provided by the user. Implies that this argument is optional.

Default Values Example

# required

Boolean

Specify that this argument is required.

# Advanced Options

# allowed

Array of Strings

Limit the allowed values to a specified whitelist. Can be used in conjunction with default or required.

Whitelist Example

# repeatable

Boolean

Specify that this argument can be provided multiple times.

The received value will be formatted as a quoted, space-delimited string which you will need to convert to array with something like eval "data=(${args[path]})".

Repeatable Argument Example

# validate

String

Apply a custom validation function.

Custom Validations
../../advanced/validations/