#!/bin/sh -e
#
# ,missing - verify if all common programs are installed

missing=0

chk() {
  for i in "${@-}"; do
    type "${i}" 2>/dev/null >&2 || {
      >&2 printf "* %s\n" "${i}"
      missing="$((missing + 1))"
    }
  done
}

printf "missing:\n"

if is-mac; then
  chk getopt gsed gtar gwhich gpatch
  chk namei pee
  chk nvim tokei
fi

if is-linux; then
  chk wl-copy ydotool
fi

# basics
chk gawk sed file less vim
chk curl ifne rsync trurl wget

# rust cli-tools
chk bat delta eza fd rg sd

# grep
chk bingrep hgrep pdfgrep

# rust benchmark/process/monitoring/diskusage utils
chk hyperfine btm dust ncdu

# monitoring
chk htop

# c programming
chk cmake flex gcc gdb git make patch

# c utilities
chk entr lr nq xe

# language/package
chk cargo jq perl ruby rust pipx

# shell
chk bash dash rlwrap shellcheck shfmt zsh

# media
chk chafa exiftool ffmpeg magick mtn timg

# markup documents
chk markdown mupdf pandoc rename

# pipe
chk aha ansifilter pv

# archive
chk bzip2 gzip unzip xz

# fuzzy
chk fzy fzf

printf '%s not found\n' "${missing}"
