What I Learned Today

I continued adding stuff to my thor bandolier today, including some sweet meta-tasks to help deal with thor. Check them out at my git repo for my thor tasks. One thing to especially look at is provision.thor. I had no idea until today that you can make a .thor directory with a main.thor file inside to drive it.

My zsh completion for thor quest continues. It is still breaking me - three hours already, and not satisfied - but I'm making progress. Here's the latest:

#compdef thor

# List of commands built into thor.
_thor_commands() {
  _values "Thor" "list" "install" "uninstall" "help" "installed" "update"
}

# Get list of all thor tasks added.
_thor_tasks() {
  compadd `thor list | grep -vP '^[\#\-]|^\s*$' | 
    sed -e '1d' -e 's/[^a-zA-Z0-9_\-\:].*$//' | grep -v '^\n$'`
}

# Normally, show all of the above.
if (( CURRENT == 2 )); then
  _thor_commands
  _thor_tasks
else
  # If we've typed 'thor install', let us look for a normal file.
  if [[ $words[2] == install ]] ; then
    _files
  # If we've typed 'thor help', just show us the built in thor commands.
  elif [[ $words[2] == help ]] ; then
    _thor_commands
  fi
fi

Published: 16 Sep 2009