diff --git a/examples/render-mandoc/docs/download.1 b/examples/render-mandoc/docs/download.1 index f600827e9..502b828c3 100644 --- a/examples/render-mandoc/docs/download.1 +++ b/examples/render-mandoc/docs/download.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 3.2 .\" -.TH "download" "1" "November 2024" "Version 0.1.0" "Sample application" +.TH "download" "1" "December 2024" "Version 0.1.0" "Sample application" .SH NAME \f[B]download\f[R] \- Sample application .SH SYNOPSIS diff --git a/examples/render-mandoc/docs/download.md b/examples/render-mandoc/docs/download.md index 99c930735..8e93e65a8 100644 --- a/examples/render-mandoc/docs/download.md +++ b/examples/render-mandoc/docs/download.md @@ -1,6 +1,6 @@ % download(1) Version 0.1.0 | Sample application % Lana Lang -% November 2024 +% December 2024 NAME ================================================== diff --git a/lib/bashly/concerns/renderable.rb b/lib/bashly/concerns/renderable.rb index 2a971ad3e..3a0961692 100644 --- a/lib/bashly/concerns/renderable.rb +++ b/lib/bashly/concerns/renderable.rb @@ -16,7 +16,7 @@ def strings # Outputs a comment that describes the view unless in production mode def view_marker(id = nil) id ||= ":#{caller_locations(1..1).first.path}" - "# #{id}" unless Settings.production? + "# #{id}" if Settings.enabled? :view_markers end # Reads a file from the userspace (Settings.source_dir) and returns diff --git a/lib/bashly/libraries/settings/settings.yml b/lib/bashly/libraries/settings/settings.yml index 84e517abf..797b87c5b 100644 --- a/lib/bashly/libraries/settings/settings.yml +++ b/lib/bashly/libraries/settings/settings.yml @@ -9,6 +9,11 @@ # If you wish to change the path to this file, set the environment variable # BASHLY_SETTINGS_PATH. + +#------------------------------------------------------------------------------- +# PATH OPTIONS +#------------------------------------------------------------------------------- + # The path containing the bashly source files source_dir: src @@ -27,6 +32,14 @@ lib_dir: lib # directory, and each command will get its own subdirectory commands_dir: ~ +# The extension to use when reading/writing partial script snippets +partials_extension: sh + + +#------------------------------------------------------------------------------- +# FORMAT OPTIONS +#------------------------------------------------------------------------------- + # Configure the bash options that will be added to the initialize function: # strict: true Bash strict mode (set -euo pipefail) # strict: false Only exit on errors (set -e) @@ -38,6 +51,11 @@ strict: false # (every 2 leading spaces will be converted to a tab character) tab_indent: false + +#------------------------------------------------------------------------------- +# INTERFACE OPTIONS +#------------------------------------------------------------------------------- + # When true, the generated script will consider any argument in the form of # `-abc` as if it is `-a -b -c`. compact_short_flags: true @@ -47,14 +65,6 @@ compact_short_flags: true # respectively. conjoined_flag_args: true -# Set to 'production' or 'development': -# env: production Generate a smaller script, without file markers -# env: development Generate with file markers -env: development - -# The extension to use when reading/writing partial script snippets -partials_extension: sh - # Show command examples (if any) whenever the user does not provide the # required arguments show_examples_on_error: false @@ -75,3 +85,28 @@ usage_colors: arg: ~ flag: ~ environment_variable: ~ + + +#------------------------------------------------------------------------------- +# FEATURE TOGGLES +#------------------------------------------------------------------------------- + +# Set to 'production' or 'development'. +# Determines which features are enabled in the rendered script. +# Use the `enable_*` options below to adjust settings for each environment. +# It is recommended to leave this set to 'development' and run +# `bashly generate --production` when the slimmer production script is needed. +env: development + +# Tweak the script output by enabling or disabling some script output. +# These options accept one of the following strings: +# - production render this feature only when env == production +# - development render this feature only when env == development +# - always render this feature in any environment +# - never do not render this feature +enable_header_comment: always +enable_bash3_bouncer: always +enable_view_markers: development +enable_inspect_args: development +enable_deps_array: always +enable_env_var_names_array: always diff --git a/lib/bashly/script/dependency.rb b/lib/bashly/script/dependency.rb index 43a533380..7c048d44c 100644 --- a/lib/bashly/script/dependency.rb +++ b/lib/bashly/script/dependency.rb @@ -1,6 +1,6 @@ module Bashly module Script - class Dependency + class Dependency < Base attr_reader :label, :commands, :help class << self diff --git a/lib/bashly/script/wrapper.rb b/lib/bashly/script/wrapper.rb index 58ff41f1e..dd59e1986 100644 --- a/lib/bashly/script/wrapper.rb +++ b/lib/bashly/script/wrapper.rb @@ -40,7 +40,7 @@ def header! def default_header result = render 'header' - result += render('bash3_bouncer') unless function_name + result += render('bash3_bouncer') unless function_name || !Settings.enabled?(:bash3_bouncer) result end diff --git a/lib/bashly/settings.rb b/lib/bashly/settings.rb index 6fb73b4b8..1a3bc0cd1 100644 --- a/lib/bashly/settings.rb +++ b/lib/bashly/settings.rb @@ -8,6 +8,12 @@ class << self :compact_short_flags, :conjoined_flag_args, :config_path, + :enable_bash3_bouncer, + :enable_deps_array, + :enable_env_var_names_array, + :enable_header_comment, + :enable_inspect_args, + :enable_view_markers, :lib_dir, :partials_extension, :private_reveal_key, @@ -35,6 +41,36 @@ def config_path @config_path ||= get(:config_path) % { source_dir: source_dir } end + def enabled?(feature) + send(:"enable_#{feature}") == 'always' || + (send(:"enable_#{feature}") == 'production' && production?) || + (send(:"enable_#{feature}") == 'development' && !production?) + end + + def enable_header_comment + @enable_header_comment ||= get :enable_header_comment + end + + def enable_bash3_bouncer + @enable_bash3_bouncer ||= get :enable_bash3_bouncer + end + + def enable_view_markers + @enable_view_markers ||= get :enable_view_markers + end + + def enable_inspect_args + @enable_inspect_args ||= get :enable_inspect_args + end + + def enable_deps_array + @enable_deps_array ||= get :enable_deps_array + end + + def enable_env_var_names_array + @enable_env_var_names_array ||= get :enable_env_var_names_array + end + def env @env ||= get(:env)&.to_sym end diff --git a/lib/bashly/views/command/default_root_script.gtx b/lib/bashly/views/command/default_root_script.gtx index 56ce3f80a..1edef2e12 100644 --- a/lib/bashly/views/command/default_root_script.gtx +++ b/lib/bashly/views/command/default_root_script.gtx @@ -1,4 +1,6 @@ > echo "# this file is located in '{{ "#{Settings.source_dir}/#{filename}" }}'" > echo "# you can edit it freely and regenerate (it will not be overwritten)" -> inspect_args +if Settings.enabled? :inspect_args + > inspect_args +end > diff --git a/lib/bashly/views/command/default_script.gtx b/lib/bashly/views/command/default_script.gtx index 0828c187a..1ec5c4f15 100644 --- a/lib/bashly/views/command/default_script.gtx +++ b/lib/bashly/views/command/default_script.gtx @@ -1,5 +1,7 @@ > echo "# this file is located in '{{ "#{Settings.source_dir}/#{filename}" }}'" > echo "# code for '{{ full_name }}' goes here" > echo "# you can edit it freely and regenerate (it will not be overwritten)" -> inspect_args +if Settings.enabled? :inspect_args + > inspect_args +end > diff --git a/lib/bashly/views/command/dependencies_filter.gtx b/lib/bashly/views/command/dependencies_filter.gtx index f8d5c670b..279c4f025 100644 --- a/lib/bashly/views/command/dependencies_filter.gtx +++ b/lib/bashly/views/command/dependencies_filter.gtx @@ -2,15 +2,6 @@ if dependencies.any? = view_marker dependencies.each do |dependency| - > if command -v {{ dependency.commands.join(' ') }} >/dev/null 2>&1; then - > deps['{{ dependency.label }}']="$(command -v {{ dependency.commands.join(' ') }} | head -n1)" - > else - > printf "{{ strings[:missing_dependency] % { dependency: dependency.name } }}\n" >&2 - if dependency.help - > printf "%s\n" "{{ dependency.help.sanitize_for_print }}" >&2 - end - > exit 1 - > fi - > + = dependency.render :filter end end diff --git a/lib/bashly/views/command/environment_variables_filter.gtx b/lib/bashly/views/command/environment_variables_filter.gtx index f95fdf873..0689d7ebc 100644 --- a/lib/bashly/views/command/environment_variables_filter.gtx +++ b/lib/bashly/views/command/environment_variables_filter.gtx @@ -2,8 +2,10 @@ if environment_variables.any? = view_marker = render(:environment_variables_default) - environment_variables.each do |env_var| - > env_var_names+=("{{ env_var.name.upcase }}") + if Settings.enabled? :env_var_names_array + environment_variables.each do |env_var| + > env_var_names+=("{{ env_var.name.upcase }}") + end end end diff --git a/lib/bashly/views/command/inspect_args.gtx b/lib/bashly/views/command/inspect_args.gtx index 3b788705a..e9d52e992 100644 --- a/lib/bashly/views/command/inspect_args.gtx +++ b/lib/bashly/views/command/inspect_args.gtx @@ -20,22 +20,26 @@ > done > fi > -> if ((${#deps[@]})); then -> readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort) -> echo -> echo deps: -> for k in "${sorted_keys[@]}"; do -> echo "- \${deps[$k]} = ${deps[$k]}" -> done -> fi -> -> if ((${#env_var_names[@]})); then -> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort) -> echo -> echo "environment variables:" -> for k in "${sorted_names[@]}"; do -> echo "- \$$k = ${!k:-}" -> done -> fi +if Settings.enabled? :deps_array + > if ((${#deps[@]})); then + > readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort) + > echo + > echo deps: + > for k in "${sorted_keys[@]}"; do + > echo "- \${deps[$k]} = ${deps[$k]}" + > done + > fi + > +end +if Settings.enabled? :env_var_names_array + > if ((${#env_var_names[@]})); then + > readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort) + > echo + > echo "environment variables:" + > for k in "${sorted_names[@]}"; do + > echo "- \$$k = ${!k:-}" + > done + > fi +end > } > diff --git a/lib/bashly/views/command/master_script.gtx b/lib/bashly/views/command/master_script.gtx index f3fc6b52b..09b894d55 100644 --- a/lib/bashly/views/command/master_script.gtx +++ b/lib/bashly/views/command/master_script.gtx @@ -4,7 +4,7 @@ = render :version_command = render :usage = render :normalize_input -= render :inspect_args unless Settings.production? += render :inspect_args if Settings.enabled? :inspect_args = render :user_lib if user_lib.any? = render :command_functions = render :parse_requirements diff --git a/lib/bashly/views/command/run.gtx b/lib/bashly/views/command/run.gtx index 6afedb5f2..9324c45a7 100644 --- a/lib/bashly/views/command/run.gtx +++ b/lib/bashly/views/command/run.gtx @@ -2,9 +2,13 @@ > run() { > declare -g -A args=() -> declare -g -A deps=() +if Settings.enabled? :deps_array + > declare -g -A deps=() +end > declare -g -a other_args=() -> declare -g -a env_var_names=() +if Settings.enabled? :env_var_names_array + > declare -g -a env_var_names=() +end > declare -g -a input=() if has_unique_args_or_flags? > declare -g -A unique_lookup=() diff --git a/lib/bashly/views/dependency/filter.gtx b/lib/bashly/views/dependency/filter.gtx new file mode 100644 index 000000000..7aa46e7b3 --- /dev/null +++ b/lib/bashly/views/dependency/filter.gtx @@ -0,0 +1,14 @@ += view_marker + +> if ! command -v {{ commands.join(' ') }} >/dev/null 2>&1; then +> printf "{{ strings[:missing_dependency] % { dependency: name } }}\n" >&2 +if help + > printf "%s\n" "{{ help.sanitize_for_print }}" >&2 +end +> exit 1 +if Settings.enabled? :deps_array + > else + > deps['{{ label }}']="$(command -v {{ commands.join(' ') }} | head -n1)" +end +> fi +> \ No newline at end of file diff --git a/lib/bashly/views/wrapper/header.gtx b/lib/bashly/views/wrapper/header.gtx index 2dd10f684..787275ab3 100644 --- a/lib/bashly/views/wrapper/header.gtx +++ b/lib/bashly/views/wrapper/header.gtx @@ -1,5 +1,7 @@ > #!/usr/bin/env bash -> # This script was generated by bashly {{ Bashly::VERSION }} (https://bashly.dannyb.co) -> # Modifying it manually is not recommended +if Settings.enabled? :header_comment + > # This script was generated by bashly {{ Bashly::VERSION }} (https://bashly.dannyb.co) + > # Modifying it manually is not recommended +end > > diff --git a/schemas/settings.json b/schemas/settings.json index d91d732f7..b78c9c92e 100644 --- a/schemas/settings.json +++ b/schemas/settings.json @@ -1,187 +1,259 @@ { - "$schema": "https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json", - "definitions": { - "color": { - "oneOf": [ - { - "type": "string", - "examples": [ - "red", - "green", - "yellow", - "blue", - "magenta", - "cyan", - "bold", - "underlined", - "red_bold", - "green_bold", - "yellow_bold", - "blue_bold", - "magenta_bold", - "cyan_bold", - "red_underlined", - "green_underlined", - "yellow_underlined", - "blue_underlined", - "magenta_underlined", - "cyan_underlined" - ] - }, - { - "type": "null" - } - ] + "$schema": "https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json", + "definitions": { + "color": { + "oneOf": [ + { + "type": "string", + "examples": [ + "red", + "green", + "yellow", + "blue", + "magenta", + "cyan", + "bold", + "underlined", + "red_bold", + "green_bold", + "yellow_bold", + "blue_bold", + "magenta_bold", + "cyan_bold", + "red_underlined", + "green_underlined", + "yellow_underlined", + "blue_underlined", + "magenta_underlined", + "cyan_underlined" + ] + }, + { + "type": "null" } + ] + } + }, + "title": "settings", + "description": "Settings of the current application\nhttps://bashly.dannyb.co/usage/settings/#settings", + "type": "object", + "properties": { + "source_dir": { + "title": "source dir", + "description": "The path containing the bashly source files\nhttps://bashly.dannyb.co/usage/settings/#source_dir", + "type": "string", + "minLength": 1, + "default": "src" }, - "title": "settings", - "description": "Settings of the current application\nhttps://bashly.dannyb.co/usage/settings/#settings", - "type": "object", - "properties": { - "source_dir": { - "title": "source dir", - "description": "The path containing the bashly source files\nhttps://bashly.dannyb.co/usage/settings/#source_dir", - "type": "string", - "minLength": 1, - "default": "src" - }, - "config_path": { - "title": "config path", - "description": "The path to bashly.yml\nhttps://bashly.dannyb.co/usage/settings/#config_path", - "type": "string", - "minLength": 1, - "default": "%{source_dir}/bashly.yml" - }, - "target_dir": { - "title": "target dir", - "description": "The path to use for creating the bash script\nhttps://bashly.dannyb.co/usage/settings/#target_dir", - "type": "string", - "minLength": 1, - "default": "." - }, - "lib_dir": { - "title": "lib dir", - "description": "The path to use for common library files, relative to source_dir\nhttps://bashly.dannyb.co/usage/settings/#lib_dir", - "type": "string", - "minLength": 1, - "default": "lib" - }, - "commands_dir": { - "title": "commands dir", - "description": "The path to use for command files, relative to source_dir\nhttps://bashly.dannyb.co/usage/settings/#commands_dir", - "oneOf": [ - { - "type": "string", - "minLength": 1 - }, - { - "type": "null" - } - ] - }, - "strict": { - "title": "strict", - "description": "Configure the bash options that will be added to the initialize function\nhttps://bashly.dannyb.co/usage/settings/#strict", - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "string", - "examples": [ - "set -o pipefail" - ] - } - ], - "default": false - }, - "tab_indent": { - "title": "tab indent", - "description": "Whether to use tabs or spaces in the generated script\nhttps://bashly.dannyb.co/usage/settings/#tab_indent", - "type": "boolean", - "default": false + "config_path": { + "title": "config path", + "description": "The path to bashly.yml\nhttps://bashly.dannyb.co/usage/settings/#config_path", + "type": "string", + "minLength": 1, + "default": "%{source_dir}/bashly.yml" + }, + "target_dir": { + "title": "target dir", + "description": "The path to use for creating the bash script\nhttps://bashly.dannyb.co/usage/settings/#target_dir", + "type": "string", + "minLength": 1, + "default": "." + }, + "lib_dir": { + "title": "lib dir", + "description": "The path to use for common library files, relative to source_dir\nhttps://bashly.dannyb.co/usage/settings/#lib_dir", + "type": "string", + "minLength": 1, + "default": "lib" + }, + "commands_dir": { + "title": "commands dir", + "description": "The path to use for command files, relative to source_dir\nhttps://bashly.dannyb.co/usage/settings/#commands_dir", + "oneOf": [ + { + "type": "string", + "minLength": 1 }, - "compact_short_flags": { - "title": "compact short flags", - "description": "Whether to expand -abc to -a -b -c in the input line\nhttps://bashly.dannyb.co/usage/settings/#compact_short_flags", - "type": "boolean", - "default": true + { + "type": "null" + } + ] + }, + "strict": { + "title": "strict", + "description": "Configure the bash options that will be added to the initialize function\nhttps://bashly.dannyb.co/usage/settings/#strict", + "oneOf": [ + { + "type": "boolean" }, - "conjoined_flag_args": { - "title": "conjoined flag args", - "description": "Whether to expand --flag=value to --flag value in the input line\nhttps://bashly.dannyb.co/usage/settings/#conjoined_flag_args", - "type": "boolean", - "default": true + { + "type": "string", + "examples": [ + "set -o pipefail" + ] + } + ], + "default": false + }, + "tab_indent": { + "title": "tab indent", + "description": "Whether to use tabs or spaces in the generated script\nhttps://bashly.dannyb.co/usage/settings/#tab_indent", + "type": "boolean", + "default": false + }, + "compact_short_flags": { + "title": "compact short flags", + "description": "Whether to expand -abc to -a -b -c in the input line\nhttps://bashly.dannyb.co/usage/settings/#compact_short_flags", + "type": "boolean", + "default": true + }, + "conjoined_flag_args": { + "title": "conjoined flag args", + "description": "Whether to expand --flag=value to --flag value in the input line\nhttps://bashly.dannyb.co/usage/settings/#conjoined_flag_args", + "type": "boolean", + "default": true + }, + "show_examples_on_error": { + "title": "show examples on error", + "description": "Whether to show command examples when the input line is missing required arguments\nhttps://bashly.dannyb.co/usage/settings/#show_examples_on_error", + "type": "boolean", + "default": true + }, + "env": { + "title": "env", + "description": "Whether to include development related comments in the generated script\nhttps://bashly.dannyb.co/usage/settings/#env", + "type": "string", + "enum": [ + "development", + "production" + ], + "default": "development" + }, + "enable_header_comment": { + "title": "enable_header_comment", + "description": "Whether to include the header comment in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_header_comment", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "always" + }, + "enable_bash3_bouncer": { + "title": "enable_bash3_bouncer", + "description": "Whether to include the code snippet that aborts when an old version of bash is detected in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_bash3_bouncer", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "always" + }, + "enable_view_markers": { + "title": "enable_view_markers", + "description": "Whether to include view marker comments in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_view_markers", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "development" + }, + "enable_inspect_args": { + "title": "enable_inspect_args", + "description": "Whether to include the inspect_args function in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_inspect_args", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "development" + }, + "enable_deps_array": { + "title": "enable_deps_array", + "description": "Whether to include the code for the dependencies array in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_deps_array", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "always" + }, + "enable_env_var_names_array": { + "title": "enable_env_var_names_array", + "description": "Whether to include the code for the env_var_names array in the generated script\nhttps://bashly.dannyb.co/usage/settings/#enable_env_var_names_array", + "type": "string", + "enum": [ + "development", + "production", + "always", + "never" + ], + "default": "always" + }, + "partials_extension": { + "title": "partials extension", + "description": "The extension to use when reading/writing partial script snippets\nhttps://bashly.dannyb.co/usage/settings/#partials_extension", + "type": "string", + "minLength": 1, + "default": "sh" + }, + "private_reveal_key": { + "title": "private reveal key", + "description": "The name of the environment variable (case sensitive) that, if set, will reveal private commands, flags and environment variables\nhttps://bashly.dannyb.co/usage/settings/#private_reveal_key", + "oneOf": [ + { + "type": "string", + "minLength": 1 }, - "show_examples_on_error": { - "title": "show examples on error", - "description": "Whether to show command examples when the input line is missing required arguments\nhttps://bashly.dannyb.co/usage/settings/#show_examples_on_error", - "type": "boolean", - "default": true + { + "type": "null" + } + ] + }, + "usage_colors": { + "title": "usage colors", + "description": "Enable and configure colorful output for --help\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", + "type": "object", + "properties": { + "caption": { + "title": "caption", + "description": "Color for captions\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", + "$ref": "#/definitions/color" }, - "env": { - "title": "env", - "description": "Whether to include development related comments in the generated script\nhttps://bashly.dannyb.co/usage/settings/#env", - "type": "string", - "enum": [ - "development", - "production" - ], - "default": "development" + "command": { + "title": "command", + "description": "Color for commands\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", + "$ref": "#/definitions/color" }, - "partials_extension": { - "title": "partials extension", - "description": "The extension to use when reading/writing partial script snippets\nhttps://bashly.dannyb.co/usage/settings/#partials_extension", - "type": "string", - "minLength": 1, - "default": "sh" + "arg": { + "title": "arg", + "description": "Color for positional arguments\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", + "$ref": "#/definitions/color" }, - "private_reveal_key": { - "title": "private reveal key", - "description": "The name of the environment variable (case sensitive) that, if set, will reveal private commands, flags and environment variables\nhttps://bashly.dannyb.co/usage/settings/#private_reveal_key", - "oneOf": [ - { - "type": "string", - "minLength": 1 - }, - { - "type": "null" - } - ] + "flag": { + "title": "flag", + "description": "Color for flags\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", + "$ref": "#/definitions/color" }, - "usage_colors": { - "title": "usage colors", - "description": "Enable and configure colorful output for --help\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", - "type": "object", - "properties": { - "caption": { - "title": "caption", - "description": "Color for captions\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", - "$ref": "#/definitions/color" - }, - "command": { - "title": "command", - "description": "Color for commands\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", - "$ref": "#/definitions/color" - }, - "arg": { - "title": "arg", - "description": "Color for positional arguments\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", - "$ref": "#/definitions/color" - }, - "flag": { - "title": "flag", - "description": "Color for flags\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", - "$ref": "#/definitions/color" - }, - "environment_variable": { - "title": "environment variable", - "description": "Color for env environment variables\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", - "$ref": "#/definitions/color" - } - }, - "additionalProperties": false + "environment_variable": { + "title": "environment variable", + "description": "Color for env environment variables\nhttps://bashly.dannyb.co/usage/settings/#usage_colors", + "$ref": "#/definitions/color" } - }, - "additionalProperties": false -} \ No newline at end of file + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/schemas/strings.json b/schemas/strings.json index 60a864b96..3b740aa2f 100644 --- a/schemas/strings.json +++ b/schemas/strings.json @@ -1,254 +1,254 @@ { - "$schema": "https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json", - "title": "strings", - "description": "Strings of the generated script\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "object", - "properties": { - "usage": { - "title": "usage", - "description": "The caption for the usage patterns\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Usage:" - }, - "options": { - "title": "options", - "description": "The caption for the options section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Options:" - }, - "global_options": { - "title": "global_options", - "description": "The caption for the options section, when a command has flags and sub-commands\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Options:" - }, - "arguments": { - "title": "arguments", - "description": "The caption for the argument section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Arguments:" - }, - "commands": { - "title": "commands", - "description": "The caption for the command section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Commands:" - }, - "examples": { - "title": "examples", - "description": "The caption for the examples section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Examples:" - }, - "environment_variables": { - "title": "environment variables", - "description": "The caption for the environment variables section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Environment Variables:" - }, - "group": { - "title": "group", - "description": "The caption template for custom command groups\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{group} Commands:" - }, - "command_alias": { - "title": "command alias", - "description": "The string template for a command alias\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Alias: %{alias}" - }, - "default_command_summary": { - "title": "default command summary", - "description": "The string template for the summary of a default command\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{summary} (default)" - }, - "required": { - "title": "required", - "description": "The string suffix for required arguments, flags, or commands\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "(required)" - }, - "repeatable": { - "title": "repeatable", - "description": "The string suffix for repeatable arguments, flags, or commands\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "(repeatable)" - }, - "default": { - "title": "default", - "description": "The string template for a default argument or flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Default: %{value}" - }, - "allowed": { - "title": "allowed", - "description": "The string template for the list of allowed values\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Allowed: %{values}" - }, - "needs": { - "title": "needs", - "description": "The string template for the list of needed flags\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Needs: %{values}" - }, - "conflicts": { - "title": "conflicts", - "description": "The string template for the list of conflicting flags\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Conflicts: %{values}" - }, - "help_flag_text": { - "title": "help flag text", - "description": "The help message for --help\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Show this help" - }, - "version_flag_text": { - "title": "version flag text", - "description": "The help message for --version\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "Show version number" - }, - "flag_requires_an_argument": { - "title": "flag requires an argument", - "description": "The error message template for missing flag argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{name} requires an argument: %{usage}" - }, - "flag_needs_another": { - "title": "flag needs another flag", - "description": "The error message template for missing flag needs\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{name} needs %{need}" - }, - "invalid_argument": { - "title": "invalid argument", - "description": "The error message template for invalid argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "invalid argument: %s" - }, - "invalid_flag": { - "title": "invalid flag", - "description": "The error message template for invalid flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "invalid option: %s" - }, - "invalid_command": { - "title": "invalid command", - "description": "The error message template for invalid command\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "invalid command: %s" - }, - "conflicting_flags": { - "title": "conflicting flags", - "description": "The error message template for conflicting flags\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "conflicting options: %s cannot be used with %s" - }, - "missing_required_argument": { - "title": "missing required argument", - "description": "The error message template for missing required argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "missing required argument: %{arg}\\nusage: %{usage}" - }, - "missing_required_flag": { - "title": "missing required flag", - "description": "The error message template for missing required flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "missing required flag: %{usage}" - }, - "missing_required_environment_variable": { - "title": "missing required environment variable", - "description": "The error message template for missing required environment variable\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "missing required environment variable: %{var}" - }, - "missing_dependency": { - "title": "missing dependency", - "description": "The error message template for missing dependency\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "missing dependency: %{dependency}" - }, - "examples_caption_on_error": { - "title": "examples caption on error", - "description": "The string to show before the examples when show_examples_on_error is enabled\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "examples:" - }, - "disallowed_flag": { - "title": "disallowed flag", - "description": "The error message template for forbidden flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{name} must be one of: %{allowed}" - }, - "disallowed_argument": { - "title": "disallowed argument", - "description": "The error message template for forbidden argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{name} must be one of: %{allowed}" - }, - "disallowed_environment_variable": { - "title": "disallowed_environment_variable", - "description": "The error message template for forbidden environment variable\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "%{name} environment variable must be one of: %{allowed}" - }, - "unsupported_bash_version": { - "title": "unsupported bash version", - "description": "The error message for unsupported Bash version\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "bash version 4 or higher is required" - }, - "validation_error": { - "title": "validation error", - "description": "The error message template for failed custom validation\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "validation error in %s:\\n%s" - }, - "environment_variable_validation_error": { - "title": "environment variable validation error", - "description": "The error message template for failed custom validation for environment variables\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", - "type": "string", - "minLength": 1, - "default": "validation error in environment variable %s:\\n%s" - } - }, - "additionalProperties": false -} \ No newline at end of file + "$schema": "https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json", + "title": "strings", + "description": "Strings of the generated script\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "object", + "properties": { + "usage": { + "title": "usage", + "description": "The caption for the usage patterns\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Usage:" + }, + "options": { + "title": "options", + "description": "The caption for the options section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Options:" + }, + "global_options": { + "title": "global_options", + "description": "The caption for the options section, when a command has flags and sub-commands\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Options:" + }, + "arguments": { + "title": "arguments", + "description": "The caption for the argument section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Arguments:" + }, + "commands": { + "title": "commands", + "description": "The caption for the command section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Commands:" + }, + "examples": { + "title": "examples", + "description": "The caption for the examples section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Examples:" + }, + "environment_variables": { + "title": "environment variables", + "description": "The caption for the environment variables section\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Environment Variables:" + }, + "group": { + "title": "group", + "description": "The caption template for custom command groups\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{group} Commands:" + }, + "command_alias": { + "title": "command alias", + "description": "The string template for a command alias\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Alias: %{alias}" + }, + "default_command_summary": { + "title": "default command summary", + "description": "The string template for the summary of a default command\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{summary} (default)" + }, + "required": { + "title": "required", + "description": "The string suffix for required arguments, flags, or commands\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "(required)" + }, + "repeatable": { + "title": "repeatable", + "description": "The string suffix for repeatable arguments, flags, or commands\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "(repeatable)" + }, + "default": { + "title": "default", + "description": "The string template for a default argument or flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Default: %{value}" + }, + "allowed": { + "title": "allowed", + "description": "The string template for the list of allowed values\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Allowed: %{values}" + }, + "needs": { + "title": "needs", + "description": "The string template for the list of needed flags\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Needs: %{values}" + }, + "conflicts": { + "title": "conflicts", + "description": "The string template for the list of conflicting flags\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Conflicts: %{values}" + }, + "help_flag_text": { + "title": "help flag text", + "description": "The help message for --help\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Show this help" + }, + "version_flag_text": { + "title": "version flag text", + "description": "The help message for --version\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "Show version number" + }, + "flag_requires_an_argument": { + "title": "flag requires an argument", + "description": "The error message template for missing flag argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{name} requires an argument: %{usage}" + }, + "flag_needs_another": { + "title": "flag needs another flag", + "description": "The error message template for missing flag needs\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{name} needs %{need}" + }, + "invalid_argument": { + "title": "invalid argument", + "description": "The error message template for invalid argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "invalid argument: %s" + }, + "invalid_flag": { + "title": "invalid flag", + "description": "The error message template for invalid flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "invalid option: %s" + }, + "invalid_command": { + "title": "invalid command", + "description": "The error message template for invalid command\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "invalid command: %s" + }, + "conflicting_flags": { + "title": "conflicting flags", + "description": "The error message template for conflicting flags\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "conflicting options: %s cannot be used with %s" + }, + "missing_required_argument": { + "title": "missing required argument", + "description": "The error message template for missing required argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "missing required argument: %{arg}\\nusage: %{usage}" + }, + "missing_required_flag": { + "title": "missing required flag", + "description": "The error message template for missing required flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "missing required flag: %{usage}" + }, + "missing_required_environment_variable": { + "title": "missing required environment variable", + "description": "The error message template for missing required environment variable\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "missing required environment variable: %{var}" + }, + "missing_dependency": { + "title": "missing dependency", + "description": "The error message template for missing dependency\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "missing dependency: %{dependency}" + }, + "examples_caption_on_error": { + "title": "examples caption on error", + "description": "The string to show before the examples when show_examples_on_error is enabled\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "examples:" + }, + "disallowed_flag": { + "title": "disallowed flag", + "description": "The error message template for forbidden flag\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{name} must be one of: %{allowed}" + }, + "disallowed_argument": { + "title": "disallowed argument", + "description": "The error message template for forbidden argument\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{name} must be one of: %{allowed}" + }, + "disallowed_environment_variable": { + "title": "disallowed_environment_variable", + "description": "The error message template for forbidden environment variable\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "%{name} environment variable must be one of: %{allowed}" + }, + "unsupported_bash_version": { + "title": "unsupported bash version", + "description": "The error message for unsupported Bash version\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "bash version 4 or higher is required" + }, + "validation_error": { + "title": "validation error", + "description": "The error message template for failed custom validation\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "validation error in %s:\\n%s" + }, + "environment_variable_validation_error": { + "title": "environment variable validation error", + "description": "The error message template for failed custom validation for environment variables\nhttps://bashly.dannyb.co/advanced/strings/#custom-strings", + "type": "string", + "minLength": 1, + "default": "validation error in environment variable %s:\\n%s" + } + }, + "additionalProperties": false +} diff --git a/spec/approvals/examples/render-mandoc b/spec/approvals/examples/render-mandoc index 5c3d0ca31..49a8c85b9 100644 --- a/spec/approvals/examples/render-mandoc +++ b/spec/approvals/examples/render-mandoc @@ -44,4 +44,4 @@ ISSUE TRACKER AUTHORS Lana Lang. -Version 0.1.0 November 2024 download(1) +Version 0.1.0 December 2024 download(1) diff --git a/spec/bashly/settings_spec.rb b/spec/bashly/settings_spec.rb index 1cf3935ee..efa4f743d 100644 --- a/spec/bashly/settings_spec.rb +++ b/spec/bashly/settings_spec.rb @@ -97,7 +97,77 @@ end end - describe 'strict_string' do + describe '::enabled?' do + context 'when the value is always' do + before { subject.enable_header_comment = 'always' } + + it 'returns true' do + expect(subject.enabled? :header_comment).to be true + end + end + + context 'when the value is never' do + before { subject.enable_header_comment = 'never' } + + it 'returns false' do + expect(subject.enabled? :header_comment).to be false + end + end + + context 'when the value is production in a production env' do + before do + subject.enable_header_comment = 'production' + subject.env = :production + end + + after { subject.env = nil } + + it 'returns true' do + expect(subject.enabled? :header_comment).to be true + end + end + + context 'when the value is production in a development env' do + before do + subject.enable_header_comment = 'production' + subject.env = :development + end + + after { subject.env = nil } + + it 'returns false' do + expect(subject.enabled? :header_comment).to be false + end + end + + context 'when the value is development in a production env' do + before do + subject.enable_header_comment = 'development' + subject.env = :production + end + + after { subject.env = nil } + + it 'returns false' do + expect(subject.enabled? :header_comment).to be false + end + end + + context 'when the value is development in a development env' do + before do + subject.enable_header_comment = 'development' + subject.env = :development + end + + after { subject.env = nil } + + it 'returns true' do + expect(subject.enabled? :header_comment).to be true + end + end + end + + describe '::strict_string' do context 'when strict is true' do before { subject.strict = true } diff --git a/support/runfile/schema.runfile b/support/runfile/schema.runfile index a5fd4bd00..b233e6cc0 100644 --- a/support/runfile/schema.runfile +++ b/support/runfile/schema.runfile @@ -6,6 +6,11 @@ action :generate do say "gb`$` #{cmd}" success = system cmd abort 'Failed' unless success + + cmd = 'yq -p yaml -o json support/schema/settings.yml > schemas/settings.json' + say "gb`$` #{cmd}" + success = system cmd + abort 'Failed' unless success end help 'Run all the test actions in this runfile' diff --git a/support/schema/README.md b/support/schema/README.md index 68af4d86c..e2f7c8418 100644 --- a/support/schema/README.md +++ b/support/schema/README.md @@ -1,6 +1,7 @@ -This is the source file for the `schemas/bashly.json` schema. +This is the source file for `schemas/bashly.json` and `schemas/settings.json` +schemas. -To regenerate the bashly.json schema, simply run: +To regenerate the, simply run: ``` $ run scheme generate @@ -8,8 +9,9 @@ $ run scheme generate from the root directory of the project. -Alternatively, run the `yq` command directly: +Alternatively, run the `yq` commands directly: ``` $ yq -p yaml -o json support/schema/bashly.yml > schemas/bashly.json +$ yq -p yaml -o json support/schema/settings.yml > schemas/settings.json ``` diff --git a/support/schema/settings.yml b/support/schema/settings.yml new file mode 100644 index 000000000..0a01aa148 --- /dev/null +++ b/support/schema/settings.yml @@ -0,0 +1,231 @@ +$schema: https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json +definitions: + color: + oneOf: + - type: string + examples: + - red + - green + - yellow + - blue + - magenta + - cyan + - bold + - underlined + - red_bold + - green_bold + - yellow_bold + - blue_bold + - magenta_bold + - cyan_bold + - red_underlined + - green_underlined + - yellow_underlined + - blue_underlined + - magenta_underlined + - cyan_underlined + - type: "null" +title: settings +description: |- + Settings of the current application + https://bashly.dannyb.co/usage/settings/#settings +type: object +properties: + source_dir: + title: source dir + description: |- + The path containing the bashly source files + https://bashly.dannyb.co/usage/settings/#source_dir + type: string + minLength: 1 + default: src + config_path: + title: config path + description: |- + The path to bashly.yml + https://bashly.dannyb.co/usage/settings/#config_path + type: string + minLength: 1 + default: '%{source_dir}/bashly.yml' + target_dir: + title: target dir + description: |- + The path to use for creating the bash script + https://bashly.dannyb.co/usage/settings/#target_dir + type: string + minLength: 1 + default: . + lib_dir: + title: lib dir + description: |- + The path to use for common library files, relative to source_dir + https://bashly.dannyb.co/usage/settings/#lib_dir + type: string + minLength: 1 + default: lib + commands_dir: + title: commands dir + description: |- + The path to use for command files, relative to source_dir + https://bashly.dannyb.co/usage/settings/#commands_dir + oneOf: + - type: string + minLength: 1 + - type: "null" + strict: + title: strict + description: |- + Configure the bash options that will be added to the initialize function + https://bashly.dannyb.co/usage/settings/#strict + oneOf: + - type: boolean + - type: string + examples: + - set -o pipefail + default: false + tab_indent: + title: tab indent + description: |- + Whether to use tabs or spaces in the generated script + https://bashly.dannyb.co/usage/settings/#tab_indent + type: boolean + default: false + compact_short_flags: + title: compact short flags + description: |- + Whether to expand -abc to -a -b -c in the input line + https://bashly.dannyb.co/usage/settings/#compact_short_flags + type: boolean + default: true + conjoined_flag_args: + title: conjoined flag args + description: |- + Whether to expand --flag=value to --flag value in the input line + https://bashly.dannyb.co/usage/settings/#conjoined_flag_args + type: boolean + default: true + show_examples_on_error: + title: show examples on error + description: |- + Whether to show command examples when the input line is missing required arguments + https://bashly.dannyb.co/usage/settings/#show_examples_on_error + type: boolean + default: true + env: + title: env + description: |- + Whether to include development related comments in the generated script + https://bashly.dannyb.co/usage/settings/#env + type: string + enum: + - development + - production + default: development + enable_header_comment: + title: enable_header_comment + description: |- + Whether to include the header comment in the generated script + https://bashly.dannyb.co/usage/settings/#enable_header_comment + type: string + enum: &feature_toggles + - development + - production + - always + - never + default: always + enable_bash3_bouncer: + title: enable_bash3_bouncer + description: |- + Whether to include the code snippet that aborts when an old version of bash is detected in the generated script + https://bashly.dannyb.co/usage/settings/#enable_bash3_bouncer + type: string + enum: *feature_toggles + default: always + enable_view_markers: + title: enable_view_markers + description: |- + Whether to include view marker comments in the generated script + https://bashly.dannyb.co/usage/settings/#enable_view_markers + type: string + enum: *feature_toggles + default: development + enable_inspect_args: + title: enable_inspect_args + description: |- + Whether to include the inspect_args function in the generated script + https://bashly.dannyb.co/usage/settings/#enable_inspect_args + type: string + enum: *feature_toggles + default: development + enable_deps_array: + title: enable_deps_array + description: |- + Whether to include the code for the dependencies array in the generated script + https://bashly.dannyb.co/usage/settings/#enable_deps_array + type: string + enum: *feature_toggles + default: always + enable_env_var_names_array: + title: enable_env_var_names_array + description: |- + Whether to include the code for the env_var_names array in the generated script + https://bashly.dannyb.co/usage/settings/#enable_env_var_names_array + type: string + enum: *feature_toggles + default: always + partials_extension: + title: partials extension + description: |- + The extension to use when reading/writing partial script snippets + https://bashly.dannyb.co/usage/settings/#partials_extension + type: string + minLength: 1 + default: sh + private_reveal_key: + title: private reveal key + description: |- + The name of the environment variable (case sensitive) that, if set, will reveal private commands, flags and environment variables + https://bashly.dannyb.co/usage/settings/#private_reveal_key + oneOf: + - type: string + minLength: 1 + - type: "null" + usage_colors: + title: usage colors + description: |- + Enable and configure colorful output for --help + https://bashly.dannyb.co/usage/settings/#usage_colors + type: object + properties: + caption: + title: caption + description: |- + Color for captions + https://bashly.dannyb.co/usage/settings/#usage_colors + $ref: '#/definitions/color' + command: + title: command + description: |- + Color for commands + https://bashly.dannyb.co/usage/settings/#usage_colors + $ref: '#/definitions/color' + arg: + title: arg + description: |- + Color for positional arguments + https://bashly.dannyb.co/usage/settings/#usage_colors + $ref: '#/definitions/color' + flag: + title: flag + description: |- + Color for flags + https://bashly.dannyb.co/usage/settings/#usage_colors + $ref: '#/definitions/color' + environment_variable: + title: environment variable + description: |- + Color for env environment variables + https://bashly.dannyb.co/usage/settings/#usage_colors + $ref: '#/definitions/color' + additionalProperties: false +additionalProperties: false