Skip to content

Commit

Permalink
Improve ./makesure -l output #47
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Sep 17, 2021
1 parent 639f36e commit 558f89d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*.iml

soft/

tmp/
21 changes: 21 additions & 0 deletions Makesurefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
@depends_on tests/17_prelude_fail.tush
@depends_on tests/18_empty_prelude.tush
@depends_on tests/19_vars_priority.tush
@depends_on tests/20_optimize_goals.tush
@depends_on tests/21_list_goals.tush

@goal tested_stable
@doc runs all tests with default awk on './makesure_stable'
Expand All @@ -149,6 +151,8 @@
@depends_on test_stable_version@tests/17_prelude_fail.tush
@depends_on test_stable_version@tests/18_empty_prelude.tush
@depends_on test_stable_version@tests/19_vars_priority.tush
@depends_on test_stable_version@tests/20_optimize_goals.tush
@depends_on test_stable_version@tests/21_list_goals.tush

@goal stable
@doc rebuilds makesure_stable & README.md for release
Expand Down Expand Up @@ -317,4 +321,21 @@ function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return
mv goawk $GOAWK
"./$GOAWK" --version

@goal installed_just @private
@reached_if [[ -f soft/just ]]
@depends_on soft_folder_created
VER="0.10.1"
echo
echo "Fetching Just $VER ..."
echo

cd "soft"

F=just-$VER-x86_64-unknown-linux-musl.tar.gz
wget "https://github.com/casey/just/releases/download/$VER/$F"
tar xzvf "$F" just
rm "$F"

"./just" --version


11 changes: 9 additions & 2 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ function checkBeforeRun( i,dep,depCnt) {
}

function doWork(\
i,j,goalName,depCnt,dep,reachedIf,reachedGoals,emptyGoals,definesLine,
i,j,goalName,gnLen,gnMaxLen,depCnt,dep,reachedIf,reachedGoals,emptyGoals,definesLine,
body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {

started("end") # end last directive
Expand All @@ -338,13 +338,20 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
list="-l" in Args || "--list" in Args
if (list || "-la" in Args || "--list-all" in Args) {
print "Available goals:"
for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
if (list && GoalsByName[goalName]) # private
continue
if ((gnLen = length(goalName)) > gnMaxLen && gnLen <= 30)
gnMaxLen = gnLen
}
for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
if (list && GoalsByName[goalName]) # private
continue
printf " "
if (goalName in Doc)
printf "%s - %s\n", goalName, Doc[goalName]
printf "%-" gnMaxLen "s : %s\n", goalName, Doc[goalName]
else
print goalName
}
Expand Down
23 changes: 23 additions & 0 deletions tests/21_list_goals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


@goal aaa
@doc some description

@goal other_goal
@doc do something important

@goal other_goal_no_doc

@goal yet_another_goal
@doc do something even more important

@goal yet_another_goal_priv @private
@doc do something even more important private

@goal yet_another_goal_looooooooooooooooooong
@doc do something even more important

@goal yet_another_goal_loooooooooooooong_private @private
@doc do something even more important

@goal hello
20 changes: 20 additions & 0 deletions tests/21_list_goals.tush
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

$ cd "$MYDIR"; ./$MAKESURE -f tests/21_list_goals.sh -l
| Available goals:
| aaa : some description
| other_goal : do something important
| other_goal_no_doc
| yet_another_goal : do something even more important
| yet_another_goal_looooooooooooooooooong : do something even more important
| hello

$ cd "$MYDIR"; ./$MAKESURE -f tests/21_list_goals.sh -la
| Available goals:
| aaa : some description
| other_goal : do something important
| other_goal_no_doc
| yet_another_goal : do something even more important
| yet_another_goal_priv : do something even more important private
| yet_another_goal_looooooooooooooooooong : do something even more important
| yet_another_goal_loooooooooooooong_private : do something even more important
| hello

0 comments on commit 558f89d

Please sign in to comment.