tome-scripts 0.12.3

Turn directories of shell scripts into full-blown CLIs
Documentation
#!/usr/bin/env bash
#
# Bootstraps tome with the example directory and executes commands.
# Any arguments passed to this script are forwarded to tome.

# Enable strict mode when executed directly (not sourced)
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    set -euo pipefail
fi

readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
readonly COMMAND_NAME="tome-example"
readonly EXAMPLE_DIR="${REPO_ROOT}/example"
readonly TOME_BIN="${TOME_BIN:-${REPO_ROOT}/target/debug/tome}"

cargo build --quiet --manifest-path "${REPO_ROOT}/Cargo.toml"
eval "$("${TOME_BIN}" init "${COMMAND_NAME}" "${EXAMPLE_DIR}" bash)"

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    "${COMMAND_NAME}" "$@"
else
    if [[ $# -gt 0 ]]; then
        "${COMMAND_NAME}" "$@"
    else
        echo "Bootstrapped tome with ${EXAMPLE_DIR}. Run '${COMMAND_NAME}' to execute commands."
    fi
fi