#compdef cu

# Completion for the Call Up (cu) command
#
# More info:
# `man zshcompsys`
# http://www.linux-mag.com/id/1106/

# Standard completion variables:
local state  # Gets set to a value when an argument action starts with `->`

# Argument line format:
# (option-exclusions)option[description]:Help-text-in-verbose-mode:action
#
# `option` can be followed by a symbol (e.g. `+`, `=`) to define how option
# values can be written . Look up `_arguments` in the `zshcompsys` manpage.
#
# `action` can be blank, a list of values, or additional completion logic.
#
_arguments \
  "-s+[baud rate]:Symbol transfer speed, depending on device:(9600)" \
  "-l+[call-up line to listen to]:Device starting with 'cu':->line"

case $state in
  (line)
    # `_files` is a general filepath completion helper
    # `-W` = working directory
    # `-g` = regexp filter
    # All completion actions should return `0` on success and non-zero on error.
    _files -W /dev -g 'cu\.*' && return 0
    ;;
esac
