mix-fast.plugin.zsh 622 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
_mix_refresh () {
  if [ -f .mix_tasks ]; then
    rm .mix_tasks
  fi
  echo "Generating .mix_tasks..." > /dev/stderr
  _mix_generate
  cat .mix_tasks
}

_mix_does_task_list_need_generating () {
  [ ! -f .mix_tasks ];
}

_mix_generate () {
15
  mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks
16
17
18
19
20
21
22
23
}

_mix () {
  if [ -f mix.exs ]; then
    if _mix_does_task_list_need_generating; then
      echo "\nGenerating .mix_tasks..." > /dev/stderr
      _mix_generate
    fi
24
25
    local tasks=(${(f)"$(cat .mix_tasks)"})
    _describe 'tasks' tasks
26
27
28
29
30
  fi
}

compdef _mix mix
alias mix_refresh='_mix_refresh'