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