Files

51 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# hello-world.sh — reference example demonstrating the StrixScripts
# conventions (see AGENTS.md). Not a real utility script — copy this
# pattern when creating an actual script, don't call this one from
# anywhere real.
#
# Full documentation: see hello-world.md in this same folder.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/common.sh
source "${SCRIPT_DIR}/../lib/common.sh"
SCRIPT_HELP=$(cat <<'HELP'
Usage: hello-world.sh [-n NAME]
Prints a greeting. Reference example only — demonstrates the SCRIPT_HELP
pattern, argument parsing, and common.sh usage that every real script in
this repo should follow.
Options:
-h, --help Show this help message and exit
-n, --name NAME Name to greet (default: world)
Examples:
./hello-world.sh
./hello-world.sh --name Danail
HELP
)
common::show_help_if_requested "$@"
name="world"
while [[ $# -gt 0 ]]; do
case "$1" in
-n|--name)
[[ $# -ge 2 ]] || common::die "--name requires a value"
name="$2"
shift 2
;;
*)
common::die "unknown argument: $1"
;;
esac
done
common::log "Greeting ${name}..."
echo "Hello, ${name}!"