#compdef scalemogrifier
#
# https://github.com/thrig/sial.org-scripts/tree/master/ly-fu

local curcontext="$curcontext" state line
typeset -A opt_args

# This could have negative or larger postive intervals, or different
# note names, but keeping it fairly simple soas not to clutter things.
_smog_intervals=(0 1 2 3 4 5 6 7 8 9 10 11 c cis d dis e f fis g gis a ais b ces des ees fes ges aes bes eis bis nl)

_arguments \
  '--direction=[direction (and magnitude) of music]:direction:' \
  '--intervals=[intervals or notes of scale]:intervals:_values -s , "intervals" $_smog_intervals' \
  '--length=[count of notes to generate]:count:' \
  '(- *)--listmodes[show available modes]' \
  '(--mode --minor)--mode=[musical mode]:mode:->modes' \
  '(--mode --minor)--minor[minor mode]' \
  '--reverse[reverse order of intervals]' \
  '(--noflats)--flats[print notes as flats]' \
  '(--flats)--noflats[print notes not as flats]' \
  '--ois=[custom output mapping interval list]:intervals:_values -s , "intervals" $_smog_intervals' \
  '--ors=[output record separator]:string:' \
  '--raw[show pitch numbers not note names]' \
  '--relative[lilypond relative output]' \
  '--transpose=[transpose by or to]:noteornum:(a b d e f g cis dis fis gis ais des ees ges aes bes)' \
  && return 0

case "$state" in
  modes)
    _wanted mode expl 'mode' compadd $(_call_program mode scalemogrifier --listmodes)
  ;;
esac
