#compdef bp

_bp_files() {
  local -a files
  # files=(${${(f@)"$(command ls "${XDG_CONFIG_HOME}/bp/")"}})
  files=("${XDG_CONFIG_HOME}/bp"/*(:t:r))
  _describe -t files "files" files
}

_bp() {
  local context curcontext="${curcontext}" state line
  typeset -A opt_args

  _arguments -C -s \
    {-i,--interactive}'[Be prompted for variables in the files frontmatter]' \
    {-l,--list}'[List all available templates]' \
    {-s,--save}'[Save a template in store]' \
    {-u,--use}'[Use a file template in store]:files:_bp_files' \
    {-h,--help}'[Show this help message]' \
    {-v,--verbose}'[Add tracebacks to error messages]' \
    && ret=0

  return "${ret}"
}

_bp "$@"
