Make the command line handling follow the long option POSIX

This make the command line handling similar to what `getopt_long_only` would do. It also fixes some trailing whitespaces because my editor does that automatically. Let me know if you want me to clean the diff.