Files
coder/cli/publickey.go
2022-04-07 22:40:27 +00:00

30 lines
568 B
Go

package cli
import (
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"github.com/coder/coder/codersdk"
)
func publickey() *cobra.Command {
return &cobra.Command{
Use: "publickey",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return xerrors.Errorf("create codersdk client: %w", err)
}
key, err := client.GitSSHKey(cmd.Context(), codersdk.Me)
if err != nil {
return xerrors.Errorf("create codersdk client: %w", err)
}
cmd.Println(key.PublicKey)
return nil
},
}
}