github.com/exercism/configlet@v3.9.3-0.20200318193232-c70be6269e71+incompatible/cmd/uuid.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/google/uuid"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  // uuidCmd represents the uuid command
    11  var uuidCmd = &cobra.Command{
    12  	Use:   "uuid",
    13  	Short: "Generate a UUID",
    14  	Long: `Generate a UUID.
    15  
    16  Each Exercism exercise needs a unique and unmutable UUID. This needs to be
    17  unique across the entire platform, not just within a track. In other words, if
    18  you have 'clock' in Go and 'clock' in Haskell, they need to have different
    19  UUIDs, even though they are based on the same problem specification.
    20  `,
    21  	Example: fmt.Sprintf("  %s uuid", binaryName),
    22  	Run:     runUUID,
    23  	Args:    cobra.ExactArgs(0),
    24  }
    25  
    26  // runUUID prints out a unique exercise UUID
    27  func runUUID(cmd *cobra.Command, args []string) {
    28  	// we don't want any UI formatting prepended to this
    29  	fmt.Println(uuid.New())
    30  }
    31  
    32  func init() {
    33  	RootCmd.AddCommand(uuidCmd)
    34  }