Revision a7ea861a htools/Ganeti/HTools/CLI.hs
b/htools/Ganeti/HTools/CLI.hs | ||
---|---|---|
31 | 31 |
( Options(..) |
32 | 32 |
, OptType |
33 | 33 |
, parseOpts |
34 |
, parseYesNo |
|
34 | 35 |
, parseISpecString |
35 | 36 |
, shTemplate |
36 | 37 |
, defaultLuxiSocket |
... | ... | |
411 | 412 |
-- * Functions |
412 | 413 |
|
413 | 414 |
-- | Helper for parsing a yes\/no command line flag. |
414 |
parseYesNo :: Bool -- ^ Default whalue (when we get a @Nothing@)
|
|
415 |
parseYesNo :: Bool -- ^ Default value (when we get a @Nothing@)
|
|
415 | 416 |
-> Maybe String -- ^ Parameter value |
416 | 417 |
-> Result Bool -- ^ Resulting boolean value |
417 | 418 |
parseYesNo v Nothing = return v |
418 | 419 |
parseYesNo _ (Just "yes") = return True |
419 | 420 |
parseYesNo _ (Just "no") = return False |
420 |
parseYesNo _ (Just s) = fail $ "Invalid choice '" ++ s ++
|
|
421 |
"', pass one of 'yes' or 'no'"
|
|
421 |
parseYesNo _ (Just s) = fail ("Invalid choice '" ++ s ++
|
|
422 |
"', pass one of 'yes' or 'no'")
|
|
422 | 423 |
|
423 | 424 |
-- | Usage info. |
424 | 425 |
usageHelp :: String -> [OptType] -> String |
Also available in: Unified diff