#!/usr/bin/env zsh
#
# man for `$DOTFILES/cheats/`
# setopt local_options extended_glob

# zhelp=("$HOME/.local/share/man/man1" "$HOME/.dotfiles/cheats" "$HOME/.config/zsh/help")
# local -a files
# files=(
#   $HOME/.local/share/man/*(N)
#   $HOME/.dotfiles/cheats/*(N)
#   $HOME/.config/zsh/help/*(N)
# )

# extname() {
#   file="$1"
#   echo ".${file##*.}"
# }

cheatsdir=${cheatsdir:-$HOME/.dotfiles/cheats}

if [ $# -eq 0 ]; then
  cd "$cheatsdir" || return
else
  # setopt local_options
  # local f
  for f in "$cheatsdir"/$1 ; do
  # command bat --color=always --language=markdown --style=snip --theme=ansi $f
  case ".${1##*.}" in
    .md)
      command bat --color=always --language=markdown --theme=ansi "$f"
      ;;
    *)
      command bat --color=always --language=man --theme=ansi "$f"
      ;;
    esac
  done
fi
# }
