local: Move --clear to it's own sub-command.

Split library setup out into a helper and move the clear option to a command.