# Argument

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

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

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

# 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 / Array of Strings

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

When using repeatable, you may provide an array here. It will be provided to your script as a space delimited string (similar to how it is provided when the user inputs values).

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

# unique

Boolean

Specify that the values for this repeatable argument must be unique. Non-unique values will be ignored.

# validate

String

Apply a custom validation function.

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