show an error message if garbage is provided to dropunused

This commit is contained in:
Joey Hess 2013-03-03 20:04:24 -04:00
parent 13cfe5c582
commit a1b6d2e057

View file

@ -62,11 +62,12 @@ withUnusedMaps a params = do
unusedSpec :: String -> [Int] unusedSpec :: String -> [Int]
unusedSpec spec unusedSpec spec
| "-" `isInfixOf` spec = range $ separate (== '-') spec | "-" `isInfixOf` spec = range $ separate (== '-') spec
| otherwise = catMaybes [readish spec] | otherwise = maybe badspec (: []) (readish spec)
where where
range (a, b) = case (readish a, readish b) of range (a, b) = case (readish a, readish b) of
(Just x, Just y) -> [x..y] (Just x, Just y) -> [x..y]
_ -> [] _ -> badspec
badspec = error $ "Expected number or range, not \"" ++ spec ++ "\""
{- Start action for unused content. Finds the number in the maps, and {- Start action for unused content. Finds the number in the maps, and
- calls either of 3 actions, depending on the type of unused file. -} - calls either of 3 actions, depending on the type of unused file. -}