Mercurial > go > multipass
view multipass-add.go @ 9:e58bfc7fc207
Make multipass files default all-readable.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 25 Oct 2015 10:45:32 -0400 |
parents | 406d3cd76739 |
children | 1246b4b9028b |
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()) os.Exit(1) } text = text[:len(text)-1] entry, password, err := auth.NewEntry(text) if err != nil { fmt.Println(err.Error()) os.Exit(1) } err = passfile.Add(entry) if err != nil { fmt.Println("Couldn't create a password:") fmt.Println(err.Error()) os.Exit(1) } fmt.Printf("New password: %s\n", password) }