Add initial scripts and project conventions
This commit is contained in:
1 parent
af9f32facc
commit
c777cf115b
14 files changed
+982
-9
No files matched your search
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/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}!"
|
||||
Reference in new issue
Block a user