ba-auto-daily/completions/ba_dailies.bash

34 lines
1.4 KiB
Bash

# Bash tab-completion for ba_dailies.sh's subcommand argument.
#
# Installed automatically by setup.sh (a `source ~/repo/ba-auto-daily/
# completions/ba_dailies.bash` line added to ~/.bashrc) -- resolves its own
# directory via BASH_SOURCE, same pattern ba_dailies.sh/ba_cron_run.sh
# already use, rather than assuming a fixed ~/ba_dailies.sh copy. The
# runtime runs directly out of this git checkout (see CLAUDE.md's
# "Deployment model"), so this always calls the ba_dailies.sh one directory
# up from wherever it was actually sourced from.
#
# The command list is queried from ba_daily.py itself (--list-commands)
# rather than duplicated here, so it can never drift from the real TASKS
# dict when a task is added, renamed, or removed.
_ba_dailies_completions() {
local cur script_dir
cur="${COMP_WORDS[COMP_CWORD]}"
# Only the first argument is a phase name; ba_dailies.sh doesn't take
# any further positional args today.
if [ "$COMP_CWORD" -ne 1 ]; then
return 0
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
local commands
commands="$("$script_dir/ba_dailies.sh" --list-commands 2>/dev/null)"
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
}
# Registered under every literal form CLAUDE.md documents running this as.
complete -F _ba_dailies_completions ba_dailies.sh
complete -F _ba_dailies_completions ./ba_dailies.sh