Add user main command and add switch as sub command

This commit is contained in:
Maidul Islam
2023-04-14 20:43:58 -07:00
parent 5508434563
commit 00442992d2
2 changed files with 13 additions and 2 deletions
+2 -1
View File
@@ -354,7 +354,7 @@ func getFreshUserCredentials(email string, password string) (*api.GetLoginOneV2R
func addNewUserPrompt() (bool, error) { func addNewUserPrompt() (bool, error) {
prompt := promptui.Select{ prompt := promptui.Select{
Label: "Infisical detects previous logged in users. Would you like to add a new user? Select[Yes/No]", Label: "A user is already logged in. Would you like to add a new user? Select[Yes/No]",
Items: []string{"No", "Yes"}, Items: []string{"No", "Yes"},
} }
@@ -362,6 +362,7 @@ func addNewUserPrompt() (bool, error) {
if err != nil { if err != nil {
return false, err return false, err
} }
return result == "Yes", err return result == "Yes", err
} }
@@ -8,6 +8,15 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var userCmd = &cobra.Command{
Use: "user",
Short: "Used manage user credentials",
DisableFlagsInUseLine: true,
Example: "infisical user",
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {},
}
var switchCmd = &cobra.Command{ var switchCmd = &cobra.Command{
Use: "switch", Use: "switch",
Short: "Used to switch between Infisical profiles", Short: "Used to switch between Infisical profiles",
@@ -50,7 +59,8 @@ var switchCmd = &cobra.Command{
} }
func init() { func init() {
rootCmd.AddCommand(switchCmd) userCmd.AddCommand(switchCmd)
rootCmd.AddCommand(userCmd)
} }
func getLoggedInUsers() ([]string, error) { func getLoggedInUsers() ([]string, error) {