add flagsToString
[hdata.git] / Util.hs
blobd127057084eaceac417dbeba5bdd2872ab34c43a
1 module Util (
2 Operation (..),
3 isHelp,
4 parseArg,
5 progName,
6 progVersion,
7 usage
8 ) where
10 import System.Environment
12 progName = "hdata"
13 progVersion = "0.0"
15 data Operation = Add
16 | Bookmark
17 | Citation
18 | Help
19 | Modify
20 | Remove
21 | Search
22 | View
23 | Version
24 deriving (Show)
26 isHelp :: String -> Bool
27 isHelp str = str `elem` ["-h","help","--help"]
29 usage :: Operation -> String
30 usage op = show op ++ " not yet implemented"
32 parseArg :: String -> Either String Operation
33 parseArg op = case op of
34 "add" -> Right Add
35 "bookmark" -> Right Bookmark
36 "citation" -> Right Citation
37 "help" -> Right Help
38 "-h" -> Right Help
39 "--help" -> Right Help
40 "modify" -> Right Modify
41 "remove" -> Right Remove
42 "search" -> Right Search
43 "view" -> Right View
44 "version" -> Right Version
45 _ -> Left $ "Invalid argument: " ++ op