cleanup cli, configs, systemd and readme
This commit is contained in:
84
cli.sh
Executable file
84
cli.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PY="$BASE_DIR/.venv/bin/python3"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./cli.sh columns [--token TOKEN] [--timeout SEC]
|
||||
./cli.sh loxone [--controller-host HOST]
|
||||
./cli.sh wb-rules [--controller-host HOST]
|
||||
./cli.sh wb-install [--station-id ID]
|
||||
./cli.sh web [--token TOKEN] [--host HOST] [--port PORT]
|
||||
|
||||
Global options may be placed before or after the command.
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" || "${1:-}" == "help" || $# -eq 0 ]]; then
|
||||
usage
|
||||
if [[ $# -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -x "$PY" ]]; then
|
||||
echo "Python venv not found: $BASE_DIR/.venv/bin/python3"
|
||||
echo "Run ./install.sh first"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
GLOBAL_ARGS=()
|
||||
POSITIONAL=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--token)
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Missing value for --token"
|
||||
exit 1
|
||||
fi
|
||||
GLOBAL_ARGS+=("$1" "$2")
|
||||
shift 2
|
||||
;;
|
||||
-h|--help|help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
POSITIONAL+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
CMD="${POSITIONAL[0]:-}"
|
||||
if [[ -z "$CMD" ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
REST_ARGS=("${POSITIONAL[@]:1}")
|
||||
|
||||
case "$CMD" in
|
||||
columns)
|
||||
exec "$PY" "$BASE_DIR/alice_plugin.py" "${GLOBAL_ARGS[@]}" stations-refresh "${REST_ARGS[@]}"
|
||||
;;
|
||||
loxone)
|
||||
exec "$PY" "$BASE_DIR/alice_plugin.py" "${GLOBAL_ARGS[@]}" templates-loxone "${REST_ARGS[@]}"
|
||||
;;
|
||||
wb-rules)
|
||||
exec "$PY" "$BASE_DIR/alice_plugin.py" "${GLOBAL_ARGS[@]}" templates-wb-rules "${REST_ARGS[@]}"
|
||||
;;
|
||||
wb-install)
|
||||
exec "$PY" "$BASE_DIR/alice_plugin.py" "${GLOBAL_ARGS[@]}" wb-install "${REST_ARGS[@]}"
|
||||
;;
|
||||
web)
|
||||
exec "$PY" "$BASE_DIR/alice_plugin.py" "${GLOBAL_ARGS[@]}" web "${REST_ARGS[@]}"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command: $CMD"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user