From 5495f69b5a527ccf38a2dc932ea8bdd751d1461a Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Sun, 25 Feb 2018 01:18:41 -0800 Subject: [PATCH] Stubs out pm key create subcommand --- cmd/pm/main.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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) }