From 558f89da505adfad2ef00fc567948e88d83dda67 Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 18 Sep 2021 01:13:00 +0300 Subject: [PATCH] Improve `./makesure -l` output #47 --- .gitignore | 2 +- Makesurefile | 21 +++++++++++++++++++++ makesure.awk | 11 +++++++++-- tests/21_list_goals.sh | 23 +++++++++++++++++++++++ tests/21_list_goals.tush | 20 ++++++++++++++++++++ 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 tests/21_list_goals.sh create mode 100644 tests/21_list_goals.tush diff --git a/.gitignore b/.gitignore index f7672b4..0b71aad 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ *.iml soft/ - +tmp/ diff --git a/Makesurefile b/Makesurefile index ecc3f7a..bc939db 100644 --- a/Makesurefile +++ b/Makesurefile @@ -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' @@ -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 @@ -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 + diff --git a/makesure.awk b/makesure.awk index 2627969..c64818d 100755 --- a/makesure.awk +++ b/makesure.awk @@ -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 @@ -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 } diff --git a/tests/21_list_goals.sh b/tests/21_list_goals.sh new file mode 100644 index 0000000..8ef7ec9 --- /dev/null +++ b/tests/21_list_goals.sh @@ -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 \ No newline at end of file diff --git a/tests/21_list_goals.tush b/tests/21_list_goals.tush new file mode 100644 index 0000000..a9433e1 --- /dev/null +++ b/tests/21_list_goals.tush @@ -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