Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make 'viewAsFieldDescr' a total function.

Fixes #980 by allowing to create config fields from options with optional
arguments. Without this change, setting the 'jobs' or 'verbose' fields in the
config file results in a fatal error on startup.
  • Loading branch information...
commit d50b2d39f77350de1c2c801f15e4f0471cc0098f 1 parent c247ec7
@23Skidoo 23Skidoo authored tibbe committed
Showing with 3 additions and 3 deletions.
  1. +3 −3 Cabal/Distribution/Simple/Command.hs
View
6 Cabal/Distribution/Simple/Command.hs
@@ -270,9 +270,9 @@ viewAsFieldDescr (OptionField n dd) = FieldDescr n get set
Just f -> return (f a)
_ -> syntaxError line val
BoolOpt _ _ _ setV _ -> (`setV` a) `liftM` runP line n parse val
- OptArg _ _ _ _readE _ _ -> -- The behaviour in this case is not clear, and it has no use so far,
- -- so we avoid future surprises by not implementing it.
- error "Command.optionToFieldDescr: feature not implemented"
+ OptArg _ _ _ readE _ _ -> ($ a) `liftM` runE line n readE val
+ -- Optional arguments are parsed just like required arguments here;
+ -- we don't provide a method to set an OptArg field to the default value.
getChoiceByLongFlag :: OptDescr b -> String -> Maybe (b->b)
getChoiceByLongFlag (ChoiceOpt alts) val = listToMaybe [ set | (_,(_sf,lf:_), set, _) <- alts
Please sign in to comment.
Something went wrong with that request. Please try again.