add correct linebreaks to usage output

This commit is contained in:
Denis Lehmann 2022-01-16 15:37:35 +01:00
parent 41b4fd31f9
commit 73300aaf18
4 changed files with 129 additions and 47 deletions

View file

@ -31,4 +31,4 @@ for n in "${NUMBERS[@]}"; do # Use parsed positional argument array
fi
done
echo "The sum is: $sftbf$sum$sftrs" # Use text formatting variables
echo "The sum is: $sftbf$sum$sftrs" # Use text formatting variables

View file

@ -7,6 +7,9 @@
# Declare sf variables
sfdesc="Greet a person."
sfargs+=("pretty-useless-flag;p;This is a pretty useless flag which is only used to show correct linebreaks of the usage. Change your terminal size and let this print again to see how the output adapts to your window")
sfargs+=("ask-for-lastname;l;Ask for lastname")
# Include sf, this could be replaced with a long oneliner
source "$(dirname $0)/../sf"
@ -14,14 +17,19 @@ source "$(dirname $0)/../sf"
# Actual script
# ----------------------
sfget "Enter your name" # Get input
echo "Hello ${sfin}!" # Use input
sfget "Enter your name" # Get input
echo "Hello ${sfin}!" # Use input
sfask "Do you want to tell me your age" # Ask for YES/no
if [ "$sfin" == true ]; then # Use answer
sfget "Enter your Age" "80" # Get input with default value
sfask "Is $sfin really your age" "no" # Use input and ask for yes/NO
if [ "$sfin" == true ]; then # Use answer
if [ "$ask_for_lastname" == true ]; then # Use variable with underscores instead of dashes
sfget "Enter your lastname" # Get input
echo "Ah I see, your lastname is ${sfin}" # Use input
fi
sfask "Do you want to tell me your age" # Ask for YES/no
if [ "$sfin" == true ]; then # Use answer
sfget "Enter your Age" "80" # Get input with default value
sfask "Is $sfin really your age" "no" # Use input and ask for yes/NO
if [ "$sfin" == true ]; then # Use answer
echo "Great!"
else
echo "I knew it!"