From 664098bd10335dc3dcb115cab89edb21dc106160 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sun, 10 Nov 2019 13:31:35 +0100 Subject: [PATCH] Improved help messages with long $target names. --- Makefile | 28 ++++++++++++++-------------- build.zsh.in | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index eb6d7d0..400c86e 100644 --- a/Makefile +++ b/Makefile @@ -340,20 +340,20 @@ help: @echo ' - MANDIR ${MANDIR}' @echo '' @echo 'Project targets: ' - @echo ' - build.zsh script' - @echo ' - build/binary.zsh script' - @echo ' - build/crystal.zsh script' - @echo ' - build/header.zsh script' - @echo ' - build/library.zsh script' - @echo ' - build/livescript.zsh script' - @echo ' - build/man.zsh script' - @echo ' - build/moon.zsh script' - @echo ' - build/ofile.zsh script' - @echo ' - build/sass.zsh script' - @echo ' - build/scdocman.zsh script' - @echo ' - build/script.zsh script' - @echo ' - build/sharedlib.zsh script' - @echo ' - build/staticlib.zsh script' + @echo ' - build.zsh script' + @echo ' - build/binary.zsh script' + @echo ' - build/crystal.zsh script' + @echo ' - build/header.zsh script' + @echo ' - build/library.zsh script' + @echo ' - build/livescript.zsh script' + @echo ' - build/man.zsh script' + @echo ' - build/moon.zsh script' + @echo ' - build/ofile.zsh script' + @echo ' - build/sass.zsh script' + @echo ' - build/scdocman.zsh script' + @echo ' - build/script.zsh script' + @echo ' - build/sharedlib.zsh script' + @echo ' - build/staticlib.zsh script' @echo '' @echo 'Makefile options:' @echo ' - gnu: false' diff --git a/build.zsh.in b/build.zsh.in index 80081ee..f978025 100644 --- a/build.zsh.in +++ b/build.zsh.in @@ -534,9 +534,26 @@ function main { write " @echo ''" write " @echo '${fg_bold[white]}Project targets: ${reset_color}'" + + # Computing how many characters should be reserved for the left part + # of those lines. The name of the target will be displayed in it. + local name_slot_size=14 + for T in ${targets[@]}; do + if [[ "${auto[$T]}" == true ]]; then + continue + fi + + if (( $#T > 22 )); then + name_slot_size=30 + break + elif (( $#T > 14 )); then + name_slot_size=22 + fi + done + for T in ${targets[@]}; do if [[ "${auto[$T]}" != true ]]; then - printf " @echo ' - ${fg_bold[yellow]}%-14s${fg[white]} ${type[$T]}${reset_color}'\n" "$T" >> $Makefile + printf " @echo ' - ${fg_bold[yellow]}%-${name_slot_size}s${fg[white]} ${type[$T]}${reset_color}'\n" "$T" >> $Makefile fi done