Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command.variables as a convenience utility for defining global command variables #563

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

DannyBen
Copy link
Owner

@DannyBen DannyBen commented Oct 22, 2024

cc #562, #366

This PR adds command.variables array, which allows defining global variables that will be available when a command (or the root script) is executed.

  • Each item in the array accepts a name, and a value.
  • The value can be anything:
    • Strings will be quoted: thevar="thevalue"
    • Arrays will be declared: declare -a thevar=(the values)
    • Associative arrays will be declared as such: declare -A thevar=(["key"]="value"...)
    • Anything else (booleans, numbers) will be placed as is: thevar=thevalue
    variables:
    # Simple value
    - name: output_folder
      value: output

    # Array
    - name: download_sources
      value:
      - youtube
      - instagram

    # Associative array
    - name: zip_options
      value:
        pattern: "*.json"
        compression_level: fast

An appropriate example was added, and running bashly doc command.variables will show the appropriate in-terminal help.

@DannyBen DannyBen merged commit b2f9a2b into master Oct 22, 2024
7 of 8 checks passed
@DannyBen DannyBen deleted the add/command-variables branch October 22, 2024 13:29
@DannyBen DannyBen added this to the 1.2.4 milestone Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant