Supporting values starting with '-' when no unsetValue exist

This commit is contained in:
Zoe Roux
2021-03-11 16:58:55 +01:00
parent 0be0973331
commit a90392e481

View File

@@ -16,6 +16,8 @@ import GetOpt.Data
import GetOpt.Options
import GetOpt.Parsers
import Data.Maybe (isNothing)
getOpt :: Parser a -> [String] -> Maybe (a, [String])
getOpt (DefParser a) args = Just (a, args)
getOpt p args = case runParser p args of
@@ -42,7 +44,7 @@ runParser p@(OptParser opt next) (identifier:args)
where
getArg :: Option a -> [String] -> Maybe (a, [String])
getArg opt (arg:args)
| head arg /= '-' = do
| head arg /= '-' || isNothing (unsetValue opt) = do
ret <- parser opt arg
return (ret, args)
| otherwise = do