mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
output generated tokens to stdout (#181)
This commit is contained in:
parent
35898412f9
commit
7c5087a212
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user