add attribution and fix several bugs

When you refactored my code, you introduced a few bugs.

You need to handle the case where the parameter value contains an equals sign.

You're also not handling the case where the next argument is something like -abc (starting with a single hyphen).

Also, don't overwrite a previously set string value with a boolean value.