Refactor the Build CLI code to be easier to read

...and use Pathname throughout.

This also throws an error if :build_dir is set to a parent directory of :source_dir, which resolves #991.