#!/bin/bash

# omarchy:summary=Manage persistent state files for Omarchy toggles and settings.
# omarchy:args=<set|clear> <state-name-or-pattern>

STATE_DIR="$HOME/.local/state/omarchy"
mkdir -p "$STATE_DIR"

COMMAND="$1"
STATE_NAME="$2"

if [[ -z $COMMAND ]]; then
  echo "Usage: omarchy-state <set|clear> <state-name-or-pattern>"
  exit 1
fi

if [[ -z $STATE_NAME ]]; then
  echo "Usage: omarchy-state $COMMAND <state-name>"
  exit 1
fi

case "$COMMAND" in
set) touch "$STATE_DIR/$STATE_NAME" ;;
clear) find "$STATE_DIR" -maxdepth 1 -type f -name "$STATE_NAME" -delete ;;
esac
