github.com/hpcng/singularity@v3.1.1+incompatible/cmd/internal/cli/key_newpair.go (about)

     1  // Copyright (c) 2017-2019, Sylabs Inc. All rights reserved.
     2  // This software is licensed under a 3-clause BSD license. Please consult the
     3  // LICENSE.md file distributed with the sources of this project regarding your
     4  // rights to use or distribute this software.
     5  
     6  package cli
     7  
     8  import (
     9  	"github.com/spf13/cobra"
    10  	"github.com/sylabs/singularity/docs"
    11  	"github.com/sylabs/singularity/internal/pkg/sylog"
    12  	"github.com/sylabs/singularity/pkg/sypgp"
    13  )
    14  
    15  func init() {
    16  	KeyNewPairCmd.Flags().SetInterspersed(false)
    17  }
    18  
    19  // KeyNewPairCmd is `singularity key newpair' and generate a new OpenPGP key pair
    20  var KeyNewPairCmd = &cobra.Command{
    21  	Args:                  cobra.ExactArgs(0),
    22  	DisableFlagsInUseLine: true,
    23  	Run: func(cmd *cobra.Command, args []string) {
    24  		if _, err := sypgp.GenKeyPair(); err != nil {
    25  			sylog.Fatalf("creating newpair failed: %v", err)
    26  		}
    27  	},
    28  
    29  	Use:     docs.KeyNewPairUse,
    30  	Short:   docs.KeyNewPairShort,
    31  	Long:    docs.KeyNewPairLong,
    32  	Example: docs.KeyNewPairExample,
    33  }