Fix crash on unknown or invalid command-line arguments
Instead, print a descriptive error message and exit gracefully.