Initial port of the index management command from Kitsune and Kuma.

This is work in progress since I need to port over some tests, too ;)