Improved help messages with long $target names.

This commit is contained in:
Luka Vandervelden 2019-11-10 13:31:35 +01:00
parent 67e1b43859
commit 664098bd10
2 changed files with 32 additions and 15 deletions

View File

@ -340,20 +340,20 @@ help:
@echo ' - MANDIR ${MANDIR}' @echo ' - MANDIR ${MANDIR}'
@echo '' @echo ''
@echo 'Project targets: ' @echo 'Project targets: '
@echo ' - build.zsh script' @echo ' - build.zsh script'
@echo ' - build/binary.zsh script' @echo ' - build/binary.zsh script'
@echo ' - build/crystal.zsh script' @echo ' - build/crystal.zsh script'
@echo ' - build/header.zsh script' @echo ' - build/header.zsh script'
@echo ' - build/library.zsh script' @echo ' - build/library.zsh script'
@echo ' - build/livescript.zsh script' @echo ' - build/livescript.zsh script'
@echo ' - build/man.zsh script' @echo ' - build/man.zsh script'
@echo ' - build/moon.zsh script' @echo ' - build/moon.zsh script'
@echo ' - build/ofile.zsh script' @echo ' - build/ofile.zsh script'
@echo ' - build/sass.zsh script' @echo ' - build/sass.zsh script'
@echo ' - build/scdocman.zsh script' @echo ' - build/scdocman.zsh script'
@echo ' - build/script.zsh script' @echo ' - build/script.zsh script'
@echo ' - build/sharedlib.zsh script' @echo ' - build/sharedlib.zsh script'
@echo ' - build/staticlib.zsh script' @echo ' - build/staticlib.zsh script'
@echo '' @echo ''
@echo 'Makefile options:' @echo 'Makefile options:'
@echo ' - gnu: false' @echo ' - gnu: false'

View File

@ -534,9 +534,26 @@ function main {
write " @echo ''" write " @echo ''"
write " @echo '${fg_bold[white]}Project targets: ${reset_color}'" 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 for T in ${targets[@]}; do
if [[ "${auto[$T]}" != true ]]; then 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 fi
done done