I have a command line script that accepts an integer value. (It is not meant as a flag in getopt).
I also use getopt() to accept some command line flags.
Sometimes my integers need to be negative. However, negative numbers trigger getopt to parse them (unless preceded by -- to stop command line flag processing, which is kind of ugly, but might be my only option).
Is there a graceful way to allow negative numbers in the command line without the '--', and by only using standard libraries/functions?
examples:
php box.php -r 5 some text arguments here
php box.php -r -5 some other text here # fails, as -5 is treated as a flag
php box.php -r -- -5 some other text here # workaround
(note: 5 and -5 are not values for the -r flag. -r is a boolean flag)