1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 06:11:12 +00:00

Merge pull request #1469 from godp1301/fix_issue_1450

Refactored make help target
This commit is contained in:
Sven Dowideit
2016-12-16 21:18:50 +10:00
committed by GitHub

View File

@@ -1,17 +1,23 @@
#!/bin/bash
set -e
#!/bin/bash -e
is_not_a_valid() {
local target=$1
[ ! -x "$target" ] || [ ! -f "$target" ]
}
get_help_statement_for() {
local target=$1
grep '^# help:' $target | sed 's/# help://'
}
cd $(dirname $0)
echo "Targets:"
echo Targets:
for i in *; do
if [ ! -x $i ] || [ ! -f $i ]; then
continue
fi
MSG=$(grep '^# help:' $i)
if [ -n "$MSG" ]; then
echo " " ${i}: $(echo $MSG | sed 's/# help://')
fi
for target in *; do
is_not_a_valid $target && continue
help_statement=$(get_help_statement_for $target)
if [ -n "$help_statement" ]; then
echo -e " $target: $help_statement"
fi
done