15 import Database
.HDBC
.Sqlite3
16 import System
.Environment
18 dbName
= progName
++ ".db"
21 tableName
= "mainTable"
34 createdb
:: Connection
-> IO Connection
35 createdb conn
= do run conn
("CREATE TABLE " ++ tableName
++ "(id INTEGER PRIMARY KEY,\
36 \ Path VARCHAR(1000),\
37 \ Title VARCHAR(1000),\
38 \ Authors VARCHAR(1000),\
39 \ Keywords VARCHAR(1000),\
40 \ Journal VARCHAR(1000),\
41 \ Volume VARCHAR(1000),\
42 \ Issue VARCHAR(1000),\
43 \ Date VARCHAR(1000),\
44 \ Pages VARCHAR(1000));") []
48 isHelp
:: String -> Bool
49 isHelp str
= str `
elem`
["-h","help","--help"]
51 opendb
:: IO Connection
53 conn
<- connectSqlite3 dbName
54 tables
<- getTables conn
55 if not (tableName `
elem` tables
)
59 usage
:: Operation
-> String
60 usage op
= show op
++ " not yet implemented"
64 parseArg
:: String -> Either String Operation
65 parseArg op
= case op
of
67 "bookmark" -> Right Bookmark
68 "citation" -> Right Citation
71 "--help" -> Right Help
72 "modify" -> Right Modify
73 "remove" -> Right Remove
74 "search" -> Right Search
76 "version" -> Right Version
77 _
-> Left
$ "Invalid argument: " ++ op