This commit is contained in:
Michael Quigley 2022-08-10 15:24:12 -04:00
parent 1d655a2b0d
commit 7f2afc13cd
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 48 additions and 37 deletions

View File

@ -21,11 +21,11 @@ func newControllerCommand() *controllerCommand {
Aliases: []string{"ctrl"}, Aliases: []string{"ctrl"},
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
} }
ccmd := &controllerCommand{ command := &controllerCommand{
cmd: cmd, cmd: cmd,
} }
cmd.Run = ccmd.run cmd.Run = command.run
return ccmd return command
} }
func (cmd *controllerCommand) run(_ *cobra.Command, args []string) { func (cmd *controllerCommand) run(_ *cobra.Command, args []string) {

View File

@ -9,7 +9,7 @@ import (
) )
func init() { func init() {
createCmd.AddCommand(createAccountCmd) createCmd.AddCommand(newCreateAccountCommand().cmd)
rootCmd.AddCommand(createCmd) rootCmd.AddCommand(createCmd)
} }
@ -18,10 +18,22 @@ var createCmd = &cobra.Command{
Short: "Create objects", Short: "Create objects",
} }
var createAccountCmd = &cobra.Command{ type createAccountCommand struct {
cmd *cobra.Command
}
func newCreateAccountCommand() *createAccountCommand {
cmd := &cobra.Command{
Use: "account", Use: "account",
Short: "create new zrok account", Short: "Create new zrok account",
Run: func(_ *cobra.Command, _ []string) { Args: cobra.ExactArgs(0),
}
command := &createAccountCommand{cmd: cmd}
cmd.Run = command.run
return command
}
func (cmd *createAccountCommand) run(_ *cobra.Command, _ []string) {
username, err := term.Prompt("New Username: ") username, err := term.Prompt("New Username: ")
if err != nil { if err != nil {
panic(err) panic(err)
@ -50,5 +62,4 @@ var createAccountCmd = &cobra.Command{
} }
logrus.Infof("api token: %v", resp.Payload.Token) logrus.Infof("api token: %v", resp.Payload.Token)
},
} }