diff --git a/retype.yml b/retype.yml index 7d88371..d2c0f3e 100644 --- a/retype.yml +++ b/retype.yml @@ -13,7 +13,7 @@ editor: branding: logo: assets/logo.svg logoDark: assets/logo-dark.svg - label: v1.3.2 + label: v1.3.3 meta: title: " - Bashly" diff --git a/src/advanced/validations.md b/src/advanced/validations.md index 070b917..67d6acd 100644 --- a/src/advanced/validations.md +++ b/src/advanced/validations.md @@ -8,8 +8,8 @@ order: 80 Bashly supports custom validation functions for your arguments, flag arguments, and environment variables. This is how it works: -1. In your bashly configuration file, arguments and flags (with arguments) - may have a `validate: function_name` option. +1. In your bashly configuration file, arguments, flags (with arguments) and + environment variables may have a `validate: function_name` option. 2. Whenever you run your script, it will look for a function with that name, prefixed by `validate_` and will run it before allowing the user input to pass. @@ -36,6 +36,11 @@ validate_file_exists() { +++ +!!!success Tip +You may specify multiple validation functions by supplying an array: +`validate: [file_exists, file_is_writable]` +!!! + ## Built-in Custom Validations diff --git a/src/configuration/argument.md b/src/configuration/argument.md index 45b1c2a..575de75 100644 --- a/src/configuration/argument.md +++ b/src/configuration/argument.md @@ -120,7 +120,7 @@ Non-unique values will be ignored. ### validate -[!badge String] +[!badge String / Array of Strings] Apply a custom validation function. diff --git a/src/configuration/environment-variable.md b/src/configuration/environment-variable.md index e3a0ef8..b7a4109 100644 --- a/src/configuration/environment-variable.md +++ b/src/configuration/environment-variable.md @@ -93,7 +93,7 @@ with [`default`](#default) or [`required`](#required). ### validate -[!badge String] +[!badge String / Array of Strings] Apply a custom validation function. diff --git a/src/configuration/flag.md b/src/configuration/flag.md index a9ffe03..f409141 100644 --- a/src/configuration/flag.md +++ b/src/configuration/flag.md @@ -219,7 +219,7 @@ specified. ### validate -[!badge String] +[!badge String / Array of Strings] Apply a custom validation function. diff --git a/src/usage/settings.md b/src/usage/settings.md index 165919d..9faa04d 100644 --- a/src/usage/settings.md +++ b/src/usage/settings.md @@ -25,6 +25,20 @@ Bashly will look for the settings file in one of these paths: - A file named `bashly-settings.yml` in the working directory. - A file named `settings.yml` in the working directory. +### Environment Overrides + +All options in the settings file (except `env`) may be specified with an +environment suffix in order to override its value for a given environment +(`production` or `development`). + +For example, when defining `formatter_production: shfmt --minify`, then +this will be the formatter used when generating the script with +`bashly generate --env production`. + +Since these values take precedence over the standard values, you can define +both (i.e. `formatter: shfmt` and `formatter_production: shfmt --minify`). + + !!!success YAML Tips - The words `yes` and `no` are equivalent to `true` and `false` - To specify a `null` value, use `~` @@ -36,13 +50,15 @@ Bashly will look for the settings file in one of these paths: All settings are optional (with their default values provided below), and can also be set with an environment variable with the same name, capitalized -and prefixed by `BASHLY_` - for example: `BASHLY_SOURCE_DIR` +and prefixed by `BASHLY_` - for example: `BASHLY_SOURCE_DIR` environment +variable is the same as specifying `source_dir` in the settings file. When setting environment variables, you can use: - `0`, `false` or `no` to represent false - `1`, `true` or `yes` to represent true + ## Path Options ### `source_dir`