#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# (C)opyright 2026 by Daniel Dietrich - MIT license
# ------------------------------------------------------------------------------
#
set -e
usage() {
echo "Usage: flatmap "
echo
echo "Commands:"
echo " env Read-only audit of API keys / access tokens for AI agents & CLIs"
echo " install Install the flatmap CLI to \$HOME/.local/bin"
}
if [ $# -eq 0 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
usage
exit 0
fi
# Run commands as bash scripts, and export this function so commands invoked
# this way can call `flatmap ` without any local installation.
# Pre-fetching scripts instead of `curl | bash -s` allows piping stdin to
# the command.
flatmap() {
local command="$1"
shift
local script
script="$(curl -fsSL "https://flatmap.ai/cli/commands/${command}")"
bash -c "$script" -- "$@"
}
export -f flatmap
flatmap "$@"