#! /usr/bin/env bash

# Executes the command line interface.

source lib/installers.sh
source lib/options.sh
source lib/settings.sh
source lib/utilities.sh
source lib/verifiers.sh

while true; do
  if [[ $# == 0 ]]; then
    printf "\n%s\n" "Usage: run OPTION"
    printf "\n%s\n" "macOS Installer Options:"
    printf "%s\n" "  Install:"
    printf "%s\n" "     b:  Install basics (fonts)."
    printf "%s\n" "     t:  Install development tools (Xcode CLI)."
    printf "%s\n" "    hf:  Install Homebrew Formulas."
    printf "%s\n" "    hc:  Install Homebrew Casks."
    printf "%s\n" "     m:  Install Mac App Store software."
    printf "%s\n" "     s:  Configure macOS system preferences."
    printf "%s\n" "     i:  Install all (executes all of the above steps in order)."
    printf "%s\n" "  Manage:"
    printf "%s\n" "     c:  Check status of installed software."
    printf "%s\n" "     C:  Caffeinate machine (prevent sleep during installation)."
    printf "%s\n" "     w:  Clean work (temp) directory."
    printf "%s\n\n" "     q:  Quit/Exit."
    read -p "Enter selection: " response
    printf "\n"
    process_option "$response"
  else
    process_option "$1"
  fi

  break
done
