diff multipass-add.go @ 0:c18bc7b9d1d9

Basic binaries. checkpassword doesn't yet work.
author Paul Fisher <paul@pfish.zone>
date Sat, 24 Oct 2015 21:32:03 -0400
parents
children faf4aad86fc9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/multipass-add.go	Sat Oct 24 21:32:03 2015 -0400
@@ -0,0 +1,30 @@
+// multipass-add allows a user to add an entry to their multipass database.
+
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"os"
+
+	"pfish.zone/go/multipass/auth"
+	"pfish.zone/go/multipass/file"
+)
+
+func main() {
+	passfile, err := file.ForMe()
+	reader := bufio.NewReader(os.Stdin)
+	fmt.Print("Describe password: ")
+	text, err := reader.ReadString('\n')
+	if err != nil {
+		fmt.Println(err.Error())
+		return
+	}
+	entry, password, err := auth.NewEntry(text)
+	if err != nil {
+		fmt.Println(err.Error())
+		return
+	}
+	passfile.Add(entry)
+	fmt.Printf("New password: %s\n", password)
+}