update style and refactor slightly

allow `~` shorthand in path to directory
move command-line flags parsing into main function
make code more idiomatic
update readme and move license into separate file