diff --git a/cmd/pm/main.go b/cmd/pm/main.go index fe66ae5..7f4c438 100644 --- a/cmd/pm/main.go +++ b/cmd/pm/main.go @@ -11,20 +11,37 @@ subcommands: keyring (key) -- interact with pm's OpenPGP keyring ` +const keyUsage = `pm keyring: interact with pm's OpenPGP keyring + +subcommands: + create (c) -- create a fresh keypair +` + func main() { if len(os.Args) < 2 { - fatal(usage) + fatalf("pm: missing subcommand\n\n%v", usage) } cmd := os.Args[1] switch cmd { case "key", "keyring": + if len(os.Args[1:]) < 2 { + fatalf("pm keyring: insufficient args\n\nusage: %v", keyUsage) + } + sub := os.Args[2] + switch sub { + case "c", "create": + fmt.Printf("creating keyring ...\n") + fatalf("NYI\n") + default: + fatalf("unknown keyring subcommand: %q\n\nusage: %v", sub, keyUsage) + } default: - fatal("uknown subcommand %q\n\nusage: %v", cmd, usage) + fatalf("uknown subcommand %q\n\nusage: %v", cmd, usage) } } -func fatal(f string, args ...interface{}) { +func fatalf(f string, args ...interface{}) { fmt.Fprintf(os.Stderr, f, args...) os.Exit(1) }