Refactored main().

Split main into smaller functions for improved readability.
This is in preparation for adding support for Windows.

Change-Id: I4786821b0350fd937e4b5d21a4ced7b7e154edc1
1 file changed