parse name/email

This commit is contained in:
Stephen McQuay 2018-02-25 01:39:11 -08:00
parent 280ba234c8
commit ea383b7a34
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5

View File

@ -1,6 +1,7 @@
package main
import (
"bufio"
"fmt"
"os"
)
@ -39,7 +40,28 @@ func main() {
sub := os.Args[2]
switch sub {
case "c", "create":
fmt.Printf("creating keyring ...\n")
var name, email string
s := bufio.NewScanner(os.Stdin)
fmt.Printf("name: ")
s.Scan()
if err := s.Err(); err != nil {
fatalf("reading name: %v\n", err)
}
name = s.Text()
fmt.Printf("email: ")
s.Scan()
if err := s.Err(); err != nil {
fatalf("reading email: %v\n", err)
}
email = s.Text()
if err := os.Stdin.Close(); err != nil {
fatalf("%v\n", err)
}
fmt.Printf("name: %q, email: %q\n", name, email)
fatalf("NYI\n")
default:
fatalf("unknown keyring subcommand: %q\n\nusage: %v", sub, keyUsage)