#!/bin/bash

# ABSTRACT: Lists all commands with descriptions extracted from "ABSTRACT" headings

source "${LIBDIR}/core-functions.sh" || exit 1

set -euo pipefail

require_bin sed sys-apps/sed
require_bin grep sys-apps/grep

for i in "${LIBEXECDIR}"/*; do
  [[ -x ${i} ]] && printf " %-30s : %s\n" \
      "$(basename "$i")" \
      "$( grep '#\s*ABSTRACT:' ${i} | sed "s/^#\s*ABSTRACT:\s*//;" | tr -d "\n" )"
done

# help: Invocation
# help:   gentoo-perl list-commands-desc
# help:
# help: Outputs:
# help:   A list of usable commands pretty printed with extracted Abstracts
# help:
# help: See Also:
# help:   gentoo-perl help list-commands
