summaryrefslogtreecommitdiff
path: root/blavote.go
diff options
context:
space:
mode:
Diffstat (limited to 'blavote.go')
-rw-r--r--blavote.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/blavote.go b/blavote.go
index 4d621b9..85e9c5e 100644
--- a/blavote.go
+++ b/blavote.go
@@ -19,8 +19,10 @@ func main() {
Version bool `short:"v" long:"version" description:"Show program version"`
Add bool `short:"a" long:"add" description:"Add a new poll"`
New bool `short:"n" long:"new" description:"Add a new poll"`
+ Username string `short:"u" long:"username" description:"Username of user adding poll"`
Args struct {
Title string
+ PollId int
Rest []string
} `positional-args:"yes"`
}
@@ -53,11 +55,14 @@ func main() {
if (opts.Version) {
fmt.Println("v" + version)
} else if (opts.Add || opts.New) {
- addPoll(db, opts.Args.Title, opts.Args.Rest)
+ err := addPoll(db, opts.Args.Title, opts.Args.Rest, opts.Username)
+ if (err == nil) {
+ fmt.Println("Poll added")
+ } else {
+ fmt.Println(err)
+ }
}
- createUser(db, "l_bratch", true)
- getUserForId(db, 1)
}
@@ -88,14 +93,9 @@ func initTables(db *sqlite3.Conn) {
db.Exec("insert into info (key, value) values('version', '0.01')")
db.Exec("create table users(id integer primary key autoincrement, name text, admin boolean)")
- db.Exec("create table polls(id integer primary key autoincrement, text text, user_id int)")
+ db.Exec("create table polls(id integer primary key autoincrement, title text, user_id int)")
db.Exec("create table options(id integer primary key autoincrement, text text, poll_id int)")
db.Exec("create table votes(id integer primary key autoincrement, user_id int, poll_id int, option_id int)")
}
-
-func addPoll(db *sqlite3.Conn, title string, options []string) {
-
-
-} \ No newline at end of file