Skip to content

Commit db365b8

Browse files
authored
Merge pull request #146 from DannyBen/add/hidden-comments
Add support for hidden comments
2 parents 7256fba + fb11eba commit db365b8

File tree

16 files changed

+106
-106
lines changed

16 files changed

+106
-106
lines changed

examples/colors/src/lib/colors.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# ---
2-
# Color functions [@bashly-upgrade colors]
3-
# This file is a part of Bashly standard library
4-
#
5-
# Usage:
6-
# Use any of the functions below to color or format a portion of a string.
7-
#
8-
# echo "before $(red this is red) after"
9-
# echo "before $(green_bold this is green_bold) after"
10-
#
11-
# Color output will be disabled if `NO_COLOR` environment variable is set
12-
# in compliance with https://no-color.org/
13-
#
14-
# ---
15-
1+
## Color functions [@bashly-upgrade colors]
2+
## This file is a part of Bashly standard library
3+
##
4+
## Usage:
5+
## Use any of the functions below to color or format a portion of a string.
6+
##
7+
## echo "before $(red this is red) after"
8+
## echo "before $(green_bold this is green_bold) after"
9+
##
10+
## Color output will be disabled if `NO_COLOR` environment variable is set
11+
## in compliance with https://no-color.org/
12+
##
1613
print_in_color() {
1714
local color="$1"
1815
shift
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [@bashly-upgrade validations]
1+
## [@bashly-upgrade validations]
22
validate_dir_exists() {
33
[[ -d "$1" ]] || echo "must be an existing directory"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [@bashly-upgrade validations]
1+
## [@bashly-upgrade validations]
22
validate_file_exists() {
33
[[ -f "$1" ]] || echo "must be an existing file"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [@bashly-upgrade validations]
1+
## [@bashly-upgrade validations]
22
validate_integer() {
33
[[ "$1" =~ ^[0-9]+$ ]] || echo "must be an integer"
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [@bashly-upgrade validations]
1+
## [@bashly-upgrade validations]
22
validate_not_empty() {
33
[[ -z "$1" ]] && echo "must not be empty"
44
}

lib/bashly/extensions/string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def wrap(length = 80)
2424
end
2525

2626
def lint
27-
gsub(/\s+\n/m, "\n\n")
27+
gsub(/\s+\n/m, "\n\n").lines.reject { |l| l =~ /^\s*##/ }.join ""
2828
end
2929

3030
end

lib/bashly/templates/lib/colors.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# ---
2-
# Color functions [@bashly-upgrade colors]
3-
# This file is a part of Bashly standard library
4-
#
5-
# Usage:
6-
# Use any of the functions below to color or format a portion of a string.
7-
#
8-
# echo "before $(red this is red) after"
9-
# echo "before $(green_bold this is green_bold) after"
10-
#
11-
# Color output will be disabled if `NO_COLOR` environment variable is set
12-
# in compliance with https://no-color.org/
13-
#
14-
# ---
15-
1+
## Color functions [@bashly-upgrade colors]
2+
## This file is a part of Bashly standard library
3+
##
4+
## Usage:
5+
## Use any of the functions below to color or format a portion of a string.
6+
##
7+
## echo "before $(red this is red) after"
8+
## echo "before $(green_bold this is green_bold) after"
9+
##
10+
## Color output will be disabled if `NO_COLOR` environment variable is set
11+
## in compliance with https://no-color.org/
12+
##
1613
print_in_color() {
1714
local color="$1"
1815
shift

lib/bashly/templates/lib/config.sh

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
# ---
2-
# Config functions [@bashly-upgrade config]
3-
# This file is a part of Bashly standard library
4-
#
5-
# Usage:
6-
# - In your script, set the CONFIG_FILE variable. For rxample:
7-
# CONFIG_FILE=settings.ini.
8-
# If it is unset, it will default to 'config.ini'.
9-
# - Use any of the functions below to access the config file.
10-
# ---
11-
12-
# Create a new config file.
13-
# There is normally no need to use this function, it is used by other
14-
# functions as needed.
1+
## Config functions [@bashly-upgrade config]
2+
## This file is a part of Bashly standard library
3+
##
4+
## Usage:
5+
## - In your script, set the CONFIG_FILE variable. For rxample:
6+
## CONFIG_FILE=settings.ini.
7+
## If it is unset, it will default to 'config.ini'.
8+
## - Use any of the functions below to access the config file.
9+
##
10+
## Create a new config file.
11+
## There is normally no need to use this function, it is used by other
12+
## functions as needed.
13+
##
1514
config_init() {
1615
CONFIG_FILE=${CONFIG_FILE:=config.ini}
1716
[[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
1817
}
1918

20-
# Get a value from the config.
21-
# Usage: result=$(config_get hello)
19+
## Get a value from the config.
20+
## Usage: result=$(config_get hello)
2221
config_get() {
2322
local key=$1
2423
local regex="^$key *= *(.+)$"
@@ -36,8 +35,8 @@ config_get() {
3635
echo "$value"
3736
}
3837

39-
# Add or update a key=value pair in the config.
40-
# Usage: config_set key value
38+
## Add or update a key=value pair in the config.
39+
## Usage: config_set key value
4140
config_set() {
4241
local key=$1
4342
shift
@@ -68,8 +67,8 @@ config_set() {
6867
printf "%b\n" "$output" > "$CONFIG_FILE"
6968
}
7069

71-
# Delete a key from the config.
72-
# Usage: config_del key
70+
## Delete a key from the config.
71+
## Usage: config_del key
7372
config_del() {
7473
local key=$1
7574

@@ -87,19 +86,19 @@ config_del() {
8786
printf "%b\n" "$output" > "$CONFIG_FILE"
8887
}
8988

90-
# Show the config file
89+
## Show the config file
9190
config_show() {
9291
config_init
9392
cat "$CONFIG_FILE"
9493
}
9594

96-
# Return an array of the keys in the config file.
97-
# Usage:
98-
#
99-
# for k in $(config_keys); do
100-
# echo "- $k = $(config_get "$k")";
101-
# done
102-
#
95+
## Return an array of the keys in the config file.
96+
## Usage:
97+
##
98+
## for k in $(config_keys); do
99+
## echo "- $k = $(config_get "$k")";
100+
## done
101+
##
103102
config_keys() {
104103
local regex="^([a-zA-Z0-9_\-\/\.]+) *="
105104

@@ -117,13 +116,13 @@ config_keys() {
117116
echo "${keys[@]}"
118117
}
119118

120-
# Returns true if the specified key exists in the config file.
121-
# Usage:
122-
#
123-
# if config_has_key "key" ; then
124-
# echo "key exists"
125-
# fi
126-
#
119+
## Returns true if the specified key exists in the config file.
120+
## Usage:
121+
##
122+
## if config_has_key "key" ; then
123+
## echo "key exists"
124+
## fi
125+
##
127126
config_has_key() {
128127
[[ $(config_get "$1") ]]
129128
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Add any function here that is needed in more than one parts of your
2-
# application, or that you otherwise wish to extract from the main function
3-
# scripts.
4-
#
5-
# Note that code here should be wrapped inside bash functions, and it is
6-
# recommended to have a separate file for each function.
7-
#
8-
# Subdirectories will also be scanned for *.sh, so you have no reason not
9-
# to organize your code neatly.
10-
#
1+
## Add any function here that is needed in more than one parts of your
2+
## application, or that you otherwise wish to extract from the main function
3+
## scripts.
4+
##
5+
## Note that code here should be wrapped inside bash functions, and it is
6+
## recommended to have a separate file for each function.
7+
##
8+
## Subdirectories will also be scanned for *.sh, so you have no reason not
9+
## to organize your code neatly.
10+
##
1111
sample_function() {
1212
echo "it works"
1313
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [@bashly-upgrade validations]
1+
## [@bashly-upgrade validations]
22
validate_dir_exists() {
33
[[ -d "$1" ]] || echo "must be an existing directory"
44
}

0 commit comments

Comments
 (0)