Skip to content

Commit

Permalink
Revert "Prevent make desc from whitespace (#167)" (#169)
Browse files Browse the repository at this point in the history
This reverts commit a7dc279.
  • Loading branch information
kuskoman authored Aug 12, 2023
1 parent a7dc279 commit e74f19d
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 12 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ All configuration variables can be checked in the [config directory](./config/).
#### Available Commands

<!--- GENERATED by ./scripts/add_descriptions_to_readme.sh --->

- `make all`: Builds binary executables for all OS (Win, Darwin, Linux).
- `make run`: Runs the Go Exporter application.
- `make build-linux`: Builds a binary executable for Linux.
Expand All @@ -125,6 +126,7 @@ All configuration variables can be checked in the [config directory](./config/).
- `make install-helm-readme`: Installs readme-generator-for-helm tool.
- `make helm-readme`: Generates Helm chart README.md file.
- `make help`: Shows info about available commands.

<!--- **************************************************** --->

#### File Structure
Expand All @@ -135,46 +137,87 @@ The binary executables are saved in the out directory.
#### Example Usage

<!--- GENERATED by ./scripts/add_descriptions_to_readme.sh --->

Builds binary executables for all OS (Win, Darwin, Linux):

make all

Runs the Go Exporter application:

make run

Builds a binary executable for Linux:

make build-linux

Builds a binary executable for Darwin:

make build-darwin

Builds a binary executable for Windows:

make build-windows

Builds a Docker image for the Go Exporter application:

make build-docker

Builds a multi-arch Docker image (`amd64` and `arm64`):

make build-docker-multi

Deletes all binary executables in the out directory:

make clean

Runs all tests:

make test

Displays test coverage report:

make test-coverage

Starts a Docker-compose configuration:

make compose

Starts a Docker-compose configuration until it's ready:

make wait-for-compose

Stops a Docker-compose configuration:

make compose-down

Verifies the metrics from the Go Exporter application:

make verify-metrics

Pulls the Docker image from the registry:

make pull

Shows logs from the Docker-compose configuration:

make logs

Minifies the binary executables:

make minify

Installs readme-generator-for-helm tool:

make install-helm-readme

Generates Helm chart README.md file:

make helm-readme

Shows info about available commands:

make help

<!--- **************************************************** --->

## Helper Scripts
Expand Down
43 changes: 31 additions & 12 deletions scripts/add_descriptions_to_readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ scriptName="$(dirname "$0")/$(basename "$0")"
function getHelp() { # get descriptions and commands from Makefile
i=0
commands=()
descriptions=()
descriptions=()

while read -r line; do
while read -r line; do
if (( i % 2 == 0 ));
then
descriptions+=( "$(echo $line | sed 's/#:[ ]*//')" )
Expand All @@ -21,7 +21,7 @@ function getHelp() { # get descriptions and commands from Makefile
done < <(
# https://stackoverflow.com/a/59087509
grep -B1 -E "^[a-zA-Z0-9_-]+\:([^\=]|$)" ./Makefile \
| grep -v -- --
| grep -v -- --
)
}

Expand All @@ -35,7 +35,7 @@ let endLine=$(grep -n "^#### File Structure" $FILE | cut -d : -f 1)-2
# Updates "Available Commands" section:

if (( startLine <= endLine));
then
then
$(sed -i "$startLine,${endLine}d" $FILE) # deletion of previous descriptions
fi

Expand All @@ -45,21 +45,29 @@ function printAvailableCommands() {
let commentLen=${#stringToWrite}-11
i=0

sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

$(sed -i "${curLine}i\\ " $FILE) # empty line
let curLine++

while (( $i < ${#commands[@]} ))
do

stringToWrite="- \`make ${commands[$i]}\`: ${descriptions[$i]}."
sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

let i++
done

$(sed -i "${curLine}i\\ " $FILE) # empty line
let curLine++

stringToWrite="<!--- $( eval $( echo printf '"\*%.0s"' {1..$commentLen} ) ) --->" # multiple '*'
sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

}

echo 'Updating "Available Commands" section...'
Expand All @@ -72,7 +80,7 @@ let startLine=$(grep -n "^#### Example Usage" $FILE | cut -d : -f 1)+2
let endLine=$(grep -n "^## Helper Scripts" $FILE | cut -d : -f 1)-2

if (( startLine <= endLine));
then
then
$(sed -i "$startLine,${endLine}d" $FILE) # deletion of previous descriptions
fi

Expand All @@ -82,29 +90,40 @@ function printExampleUsage() {
let commentLen=${#stringToWrite}-11
i=0

sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

$(sed -i "${curLine}i\\ " $FILE) # empty line
let curLine++

while (( $i < ${#commands[@]} ))
do
stringToWrite="${descriptions[$i]}:"
sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

$(sed -i "${curLine}i\\ " $FILE)
let curLine++

stringToWrite=" make ${commands[$i]}" # 4 spaces for tab (DON'T CHANGE IT)
sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

$(sed -i "${curLine}i\\ " $FILE)
let curLine++

let i++
done

stringToWrite="<!--- $( eval $( echo printf '"\*%.0s"' {1..$commentLen} ) ) --->" # multiple '*'
sed -i "${curLine}i\\${stringToWrite}" $FILE
$(sed -i "${curLine}i\\${stringToWrite}" $FILE)
let curLine++

}

echo 'Updating "Example Usage" section...'

printExampleUsage

echo 'Done.'

0 comments on commit e74f19d

Please sign in to comment.