diff --git a/spec/fixtures/workspaces/config-lib/.gitignore b/spec/fixtures/workspaces/config-lib/.gitignore index d3a4c581..b1260219 100644 --- a/spec/fixtures/workspaces/config-lib/.gitignore +++ b/spec/fixtures/workspaces/config-lib/.gitignore @@ -1 +1,2 @@ download +src/lib diff --git a/spec/fixtures/workspaces/config-lib/src/lib/config.sh b/spec/fixtures/workspaces/config-lib/src/lib/config.sh deleted file mode 100644 index 562b3bdc..00000000 --- a/spec/fixtures/workspaces/config-lib/src/lib/config.sh +++ /dev/null @@ -1,129 +0,0 @@ -# --- -# Config functions -# This file is a part of Bashly standard library -# -# Usage: -# - In your script, set the CONFIG_FILE variable. For rxample: -# CONFIG_FILE=settings.ini. -# If it is unset, it will default to 'config.ini'. -# - Use any of the functions below to access the config file. -# --- - -# Create a new config file. -# There is normally no need to use this function, it is used by other -# functions as needed. -config_init() { - CONFIG_FILE=${CONFIG_FILE:=config.ini} - [[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE" -} - -# Get a value from the config. -# Usage: result=$(config_get hello) -config_get() { - local key=$1 - local regex="^$key *= *(.+)$" - local value="" - - config_init - - while IFS= read -r line || [ -n "$line" ]; do - if [[ $line =~ $regex ]]; then - value="${BASH_REMATCH[1]}" - break - fi - done < "$CONFIG_FILE" - - echo "$value" -} - -# Add or update a key=value pair in the config. -# Usage: config_set key value -config_set() { - local key=$1 - shift - local value="$*" - - config_init - - local regex="^($key) *= *.+$" - local output="" - local found_key="" - local newline - - while IFS= read -r line || [ -n "$line" ]; do - newline=$line - if [[ $line =~ $regex ]]; then - found_key="${BASH_REMATCH[1]}" - newline="$key = $value" - output="$output$newline\n" - elif [[ $line ]]; then - output="$output$line\n" - fi - done < "$CONFIG_FILE" - - if [[ -z $found_key ]]; then - output="$output$key = $value\n" - fi - - printf "%b\n" "$output" > "$CONFIG_FILE" -} - -# Delete a key from the config. -# Usage: config_del key -config_del() { - local key=$1 - - local regex="^($key) *=" - local output="" - - config_init - - while IFS= read -r line || [ -n "$line" ]; do - if [[ $line ]] && [[ ! $line =~ $regex ]]; then - output="$output$line\n" - fi - done < "$CONFIG_FILE" - - printf "%b\n" "$output" > "$CONFIG_FILE" -} - -# Show the config file -config_show() { - config_init - cat "$CONFIG_FILE" -} - -# Return an array of the keys in the config file. -# Usage: -# -# for k in $(config_keys); do -# echo "- $k = $(config_get "$k")"; -# done -# -config_keys() { - local regex="^([a-zA-Z0-9_\-\/\.]+) *=" - - config_init - - local keys=() - local key - - while IFS= read -r line || [ -n "$line" ]; do - if [[ $line =~ $regex ]]; then - key="${BASH_REMATCH[1]}" - keys+=("$key") - fi - done < "$CONFIG_FILE" - echo "${keys[@]}" -} - -# Returns true if the specified key exists in the config file. -# Usage: -# -# if config_has_key "key" ; then -# echo "key exists" -# fi -# -config_has_key() { - [[ $(config_get "$1") ]] -} diff --git a/spec/fixtures/workspaces/empty-args/README.md b/spec/fixtures/workspaces/empty-args/README.md new file mode 100644 index 00000000..15849497 --- /dev/null +++ b/spec/fixtures/workspaces/empty-args/README.md @@ -0,0 +1,2 @@ +This fixture ensures that empty args and flag args are supported +Reference issue: https://github.com/DannyBen/bashly/pull/135 diff --git a/spec/fixtures/workspaces/empty-args/test.sh b/spec/fixtures/workspaces/empty-args/test.sh index aa44d450..e9af808e 100644 --- a/spec/fixtures/workspaces/empty-args/test.sh +++ b/spec/fixtures/workspaces/empty-args/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# This fixture tests Bash 4+-only syntax -# It is executed as part of the Runfile examples test +# This fixture ensures that empty args and flag args are supported +# Reference issue: https://github.com/DannyBen/bashly/pull/135 bundle exec bashly generate diff --git a/spec/fixtures/workspaces/validation-functions/.gitignore b/spec/fixtures/workspaces/validation-functions/.gitignore index bd32b165..b59ed826 100644 --- a/spec/fixtures/workspaces/validation-functions/.gitignore +++ b/spec/fixtures/workspaces/validation-functions/.gitignore @@ -1,3 +1,3 @@ src/*.sh -src/validations/*.sh +src/lib validate \ No newline at end of file diff --git a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_dir_exists.sh b/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_dir_exists.sh deleted file mode 100644 index fd1d0220..00000000 --- a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_dir_exists.sh +++ /dev/null @@ -1,3 +0,0 @@ -validate_dir_exists() { - [[ -d "$1" ]] || echo "must be an existing directory" -} diff --git a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_file_exists.sh b/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_file_exists.sh deleted file mode 100644 index 38fde5a9..00000000 --- a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_file_exists.sh +++ /dev/null @@ -1,3 +0,0 @@ -validate_file_exists() { - [[ -f "$1" ]] || echo "must be an existing file" -} diff --git a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_integer.sh b/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_integer.sh deleted file mode 100644 index 84b8552f..00000000 --- a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_integer.sh +++ /dev/null @@ -1,3 +0,0 @@ -validate_integer() { - [[ "$1" =~ ^[0-9]+$ ]] || echo "must be an integer" -} \ No newline at end of file diff --git a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_not_empty.sh b/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_not_empty.sh deleted file mode 100644 index f9763a17..00000000 --- a/spec/fixtures/workspaces/validation-functions/src/lib/validations/validate_not_empty.sh +++ /dev/null @@ -1,3 +0,0 @@ -validate_not_empty() { - [[ -z "$1" ]] && echo "must not be empty" -}