Extract cli repository handling and support IVORY_REPOSITORY env

This is pretty hacky, but I _think_ something like this is better than nothing until we upgrade to Pirate.