output generated tokens to stdout (#181)

This commit is contained in:
Michael Quigley 2023-01-24 13:46:52 -05:00
parent 35898412f9
commit 7c5087a212
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -2,7 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"github.com/jaevor/go-nanoid" "github.com/jaevor/go-nanoid"
"github.com/openziti/zrok/rest_client_zrok/admin" "github.com/openziti/zrok/rest_client_zrok/admin"
"github.com/openziti/zrok/rest_model_zrok" "github.com/openziti/zrok/rest_model_zrok"
@ -23,13 +22,13 @@ type adminGenerateCommand struct {
func newAdminGenerateCommand() *adminGenerateCommand { func newAdminGenerateCommand() *adminGenerateCommand {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "generate", Use: "generate",
Short: "Generate invite tokens (default: 5)", Short: "Generate invite tokens",
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
} }
command := &adminGenerateCommand{cmd: cmd} command := &adminGenerateCommand{cmd: cmd}
cmd.Run = command.run cmd.Run = command.run
cmd.Flags().IntVar(&command.amount, "amount", 5, "Amount of tokens to generate") cmd.Flags().IntVarP(&command.amount, "count", "n", 5, "Number of tokens to generate")
return command return command
} }
@ -67,7 +66,10 @@ func (cmd *adminGenerateCommand) run(_ *cobra.Command, args []string) {
} }
panic(err) panic(err)
} }
fmt.Printf("generated %d tokens\n", len(tokens))
for _, token := range tokens {
fmt.Println(token)
}
} }
func createToken() (string, error) { func createToken() (string, error) {