rank-writing.py: Restructure code.

Add ability to run subsets of the commands.