view multipass-add.go @ 1:faf4aad86fc9

Make checkpassword work; fix minor bug in add.
author Paul Fisher <paul@pfish.zone>
date Sat, 24 Oct 2015 21:48:38 -0400
parents c18bc7b9d1d9
children a4fa4f28b472
line wrap: on
line source

// 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
	}
	text = text[:-1]
	entry, password, err := auth.NewEntry(text)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	passfile.Add(entry)
	fmt.Printf("New password: %s\n", password)
}