added help to rain, fixed french comments
This commit is contained in:
@@ -39,33 +39,73 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
rain()
|
||||
{
|
||||
local step_duration=0.050
|
||||
local base_color="white" # Par défaut
|
||||
show_usage() {
|
||||
echo -e "Usage: rain [OPTIONS]"
|
||||
echo -e ""
|
||||
echo -e "Options:"
|
||||
echo -e " -s, --speed NUM Set the drop delay in seconds (default: 0.050)."
|
||||
echo -e " Lower values = faster rain."
|
||||
echo -e " -c, --color COLOR Set the color theme (default: white)."
|
||||
echo -e " -h, --help Display this help message and exit."
|
||||
echo -e ""
|
||||
echo -e "Available Colors:"
|
||||
echo -e " \e[32mgreen\e[0m : The classic Matrix digital rain"
|
||||
echo -e " \e[34mblue\e[0m : Deep ocean blue gradients"
|
||||
echo -e " \e[31mred\e[0m : Crimson/Blood rain"
|
||||
echo -e " \e[33myellow\e[0m : Amber and gold tones"
|
||||
echo -e " \e[36mcyan\e[0m : Electric cyan/turquoise"
|
||||
echo -e " white : Greyscale and white (original style)"
|
||||
echo -e ""
|
||||
echo -e "Example: rain --color green --speed 0.03"
|
||||
}
|
||||
|
||||
# 1. Analyse des arguments
|
||||
local step_duration=0.050
|
||||
local base_color="white" # default color scheme, can be overridden by --color
|
||||
|
||||
# Analyse arguments
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
-s|--speed) step_duration="$2"; shift ;;
|
||||
-c|--color) base_color="$2"; shift ;;
|
||||
*) echo "Usage: rain [-s speed] [-c color]"; return 1 ;;
|
||||
-s|--speed)
|
||||
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||
step_duration="$2"; shift
|
||||
else
|
||||
echo -e "\e[31mError: --speed requires a numeric value.\e[0m"
|
||||
show_usage && return 1
|
||||
fi
|
||||
;;
|
||||
-c|--color)
|
||||
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||
base_color="$2"; shift
|
||||
else
|
||||
echo -e "\e[31mError: --color requires a color name.\e[0m"
|
||||
show_usage && return 1
|
||||
fi
|
||||
;;
|
||||
-h|--help)
|
||||
show_usage && return 0
|
||||
;;
|
||||
*)
|
||||
echo -e "\e[31mUnknown option: $1\e[0m"
|
||||
show_usage && return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# 2. Définition de la palette de couleurs (Gradients 256-couleurs)
|
||||
# Define colors (256-colors gradients)
|
||||
local rain_colors=()
|
||||
case $base_color in
|
||||
green) # Vert style Matrix
|
||||
green) # Matrix style green
|
||||
for i in {22..28} {34..40} {46..48}; do rain_colors+=("\e[38;5;${i}m"); done ;;
|
||||
blue) # Bleu profond à clair
|
||||
blue) # Deep ocean blues
|
||||
for i in {17..21} {27..33} {39..45}; do rain_colors+=("\e[38;5;${i}m"); done ;;
|
||||
red) # Rouge sang à vif
|
||||
red) # Crimson / blood red
|
||||
for i in {52..52} {88..88} {124..124} {160..160} {196..201}; do rain_colors+=("\e[38;5;${i}m"); done ;;
|
||||
yellow) # Ambre / Or
|
||||
yellow) # Amber / gold
|
||||
for i in {58..58} {100..100} {142..142} {184..184} {226..229}; do rain_colors+=("\e[38;5;${i}m"); done ;;
|
||||
cyan) # Turquoise
|
||||
cyan) # Electric cyan / turquoise
|
||||
for i in {30..31} {37..38} {44..45} {50..51}; do rain_colors+=("\e[38;5;${i}m"); done ;;
|
||||
*) # Gris/Blanc par défaut (ton script original)
|
||||
*) # Greyscale / white (original style)
|
||||
rain_colors=("\e[37m" "\e[37;1m")
|
||||
for i in {244..255}; do rain_colors+=("\e[38;5;${i}m"); done ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user