diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2016-10-01 21:56:29 +0200 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2016-10-01 21:56:29 +0200 |
commit | d01892150eed9d58210eb40b7c005d5fa8e93238 (patch) | |
tree | f9d37f3d5b4f0d9afd01755801826713f47d83c3 /create_public_key.go | |
parent | faaf7d8859895767b5e64d32c14d561d6fdb5a14 (diff) |
rework program flow
This commit is a complete rebuild of pkictl. Before everything was all
over the place and adding new commands was kind of a hassle.
Now each command has its own file and can be adjusted on a command
basis. Options are still used by the same name, but can now use
different descriptions.
Diffstat (limited to 'create_public_key.go')
-rw-r--r-- | create_public_key.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/create_public_key.go b/create_public_key.go new file mode 100644 index 0000000..93c0677 --- /dev/null +++ b/create_public_key.go @@ -0,0 +1,26 @@ +package main + +import ( + "flag" +) + +func CreatePublicKey(args []string) error { + fs := flag.NewFlagSet("pkictl create-public-key", flag.ExitOnError) + flagPrivate := fs.String("private-key", "", "path to the private key or read from stdin") + flagOutput := fs.String("output", "stdout", "write private key to file") + fs.Parse(args) + + pk, err := loadPrivateKey(*flagPrivate) + if err != nil { + return err + } + + out, err := openOutput(*flagOutput) + if err != nil { + return err + } + defer out.Close() + + pub := pk.Public() + return writePem(pub, out) +} |