#compdef backlog

# Zsh completion script for backlog CLI
#
# NOTE: This script is embedded in the backlog binary and installed automatically
# via 'backlog completion install'. This file serves as reference documentation.
#
# Installation:
#   - Recommended: backlog completion install --shell zsh
#   - Manual: Copy this file to a directory in your $fpath and run compinit

_backlog() {
	# Get the current command line buffer and cursor position
	local line=$BUFFER
	local point=$CURSOR

	# Call the backlog completion command to get dynamic completions
	# The __complete command returns one completion per line
	local -a completions
	completions=(${(f)"$(backlog completion __complete "$line" "$point" 2>/dev/null)"})

	# Check if we got any completions
	if (( ${#completions[@]} == 0 )); then
		# No completions available
		return 1
	fi

	# Present the completions to the user
	# _describe shows completions with optional descriptions
	# The first argument is the tag name shown in completion groups
	_describe 'backlog commands' completions
}

# Register the completion function for the backlog command
compdef _backlog backlog
