57 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# omoa — Toggle oh-my-openagent on/off
# =============================================================================
#
# PURPOSE:
# Simple CLI command to toggle oh-my-openagent on/off.
# Creates or deletes the state file, then restarts the OpenCode server.
#
# USAGE:
# omoa — Toggle omoa (enable if disabled, disable if enabled)
# omoa on — Enable omoa
# omoa off — Disable omoa
# omoa status — Check if omoa is enabled
#
# UPSTREAM REPO:
# https://git.hibbhome.com/Hibbhome/opencode-omoa-toggle
#
# CREATED: 2026-05-03
# =============================================================================
STATE_FILE="$HOME/.config/opencode/omoa-enabled"
case "${1:-toggle}" in
on|enable)
touch "$STATE_FILE"
systemctl --user restart opencode-serve.service
echo "oh-my-openagent ENABLED. Server restarting..."
;;
off|disable)
rm -f "$STATE_FILE"
systemctl --user restart opencode-serve.service
echo "oh-my-openagent DISABLED. Server restarting..."
;;
status)
if [ -f "$STATE_FILE" ]; then
echo "oh-my-openagent is ENABLED"
else
echo "oh-my-openagent is DISABLED"
fi
;;
toggle)
if [ -f "$STATE_FILE" ]; then
rm -f "$STATE_FILE"
systemctl --user restart opencode-serve.service
echo "oh-my-openagent DISABLED. Server restarting..."
else
touch "$STATE_FILE"
systemctl --user restart opencode-serve.service
echo "oh-my-openagent ENABLED. Server restarting..."
fi
;;
*)
echo "Usage: omoa [on|off|status|toggle]"
;;
esac