about summary refs log tree commit diff
path: root/Completion/Darwin/Command/_osascript
blob: 5e6cebab54b5b25d85082377b76e8f31f7a4c69d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#compdef osascript

local ret=1
local -a context line state state_descr tmp
local -A opt_args val_args

_arguments -s -S : \
  '-l+[specify script language]: :->languages' \
  '(:)*-e+[execute specified line of script]:script' \
  '-i[run interactively]' \
  '*-s+[specify output style]: :->modifiers' \
  '(-e)1:script file:_files' \
&& ret=0

case $state in
  languages)
    # So far, the three languages specified here are the only ones supported,
    # but adding the output of osalang makes this future-proof
    _values 'script language' \
      AppleScript JavaScript 'Generic Scripting System' \
      ${(f)"$( _call_program languages command osalang )"} \
    && ret=0
    ;;
  modifiers)
    _values -S '' 'output modifier flag' \
      'h[print values in human-readable form]' \
      's[print values in recompilable source form]' \
      'e[print script errors to stderr]' \
      'o[print script errors to stdout]' \
    && ret=0
    ;;
esac

return ret