Command link args and ui/logic split

Added ability to give command line arguments. Split logic out from UI so
a GUI can more easily be built in future.