add clear example

This commit is contained in:
Denis Lehmann 2022-04-23 10:27:28 +02:00
parent 0a23684b82
commit aa92dda307
2 changed files with 94 additions and 0 deletions

View file

@ -166,6 +166,8 @@
echo "${sftbf}${sftr}framework${sftrs}"
#+end_src
Look at the [[#clear][clear]] example to see some of them in action.
** Examples
:properties:
:custom_id: examples
@ -255,6 +257,66 @@
go
#+end_example
*** Clear
:properties:
:custom_id: clear
:end:
This script shows the usage of color formatting variables and =$sftclr=:
#+begin_src sh
#!/usr/bin/env bash
# ----------------------
# sf -- script framework
# ----------------------
# Declare sf variables
sfdesc="Show the usage of color variables and \$sftclr."
# Include sf, this could be replaced with a long oneliner
source "$(dirname $0)/sf"
# ----------------------
# Actual script
# ----------------------
echo -n "${sftbf}" # Output everything from here bold
echo "${sftr}These" # Red
sleep 0.5
echo "${sftm}lines" # Magenta
sleep 0.5
echo "${sftb}will" # Blue
sleep 0.5
echo "${sftc}delete" # Cyan
sleep 0.5
echo "${sftg}themselves" # Green
sleep 1
echo "${sfty}now!" # Yellow
sleep 0.5
echo -n "${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}" # Clear six lines
echo "${sftblk}${sftr}T${sftm}a${sftb}d${sftc}a${sftg}a${sfty}!" # Blinking colorful
echo -n "${sftrs}" # Reset text formatting
#+end_src
The produced usage is:
#+begin_example
Usage: clear [OPTIONS]
Show the usage of color variables and $sftclr.
OPTIONS
-h, --help Show this help message and exit
#+end_example
The execution results in this:
#+begin_example
$ ./clear
Tadaa!
#+end_example
*** Add
This script adds numbers and shows the usage of =sfparr=:

32
examples/clear Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# ----------------------
# sf -- script framework
# ----------------------
# Declare sf variables
sfdesc="Show the usage of color variables and \$sftclr."
# Include sf, this could be replaced with a long oneliner
source "$(dirname $0)/../sf"
# ----------------------
# Actual script
# ----------------------
echo -n "${sftbf}" # Output everything from here bold
echo "${sftr}These" # Red
sleep 0.5
echo "${sftm}lines" # Magenta
sleep 0.5
echo "${sftb}will" # Blue
sleep 0.5
echo "${sftc}delete" # Cyan
sleep 0.5
echo "${sftg}themselves" # Green
sleep 1
echo "${sfty}now!" # Yellow
sleep 0.5
echo -n "${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}${sftclr}" # Clear six lines
echo "${sftblk}${sftr}T${sftm}a${sftb}d${sftc}a${sftg}a${sfty}!" # Blinking colorful
echo -n "${sftrs}" # Reset text formatting