#!/usr/bin/env bash EX_USAGE=64 function print_usage () { cat <<-EOF usage: code-review [--help] [] Commands: changed-files List names of files changed commits One-line log of commits diff Unified diff of changes difftool Diff of all changes with Vim and Fugitive start Start a review with a given base revision stat Stat file changes EOF } function program_exists () { local program="$1" command -v "$program" > /dev/null } program="code-review" subcommand="$1" shift if [ -z "$subcommand" ] || [ "$1" = '--help' ] || [ "$1" = '-h' ]; then print_usage exit "$EX_USAGE" fi if ! program_exists "${program}-${subcommand}"; then echo >&2 "${program}: '${subcommand}' is not a ${program} command. See '${program} --help'" exit "$EX_USAGE" fi eval "${program}-${subcommand}" "$@"