diff --git a/cli/cmd/deviceCreate.go b/cli/cmd/deviceCreate.go index efd182a0dfcb0516684fb79a0bd3d74e7aec7048..d8380a581c2d27ecd75f6451b7efff6351934161 100644 --- a/cli/cmd/deviceCreate.go +++ b/cli/cmd/deviceCreate.go @@ -87,8 +87,14 @@ if they diverge from the default credentials (user:'admin' and pw:'arista').`, for _, r := range resp.GetResponses() { spinner.Success("Device has been created with ID: ", r.GetId()) } + return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + deviceName, opcode, address, username, password = "", "", "", "", "" + }, } var deviceName string @@ -100,6 +106,6 @@ func init() { deviceCreateCmd.Flags().StringVar(&deviceName, "name", "", "add a device name (optional)") deviceCreateCmd.Flags().StringVar(&opcode, "type", "", "generation target (csbi or plugin)") deviceCreateCmd.Flags().StringVarP(&address, "address", "a", "", "address of a gnmi target, e.g. 192.168.1.1:6030") - deviceCreateCmd.Flags().StringVarP(&username, "username", "u", "admin", "username for a gnmi resource") - deviceCreateCmd.Flags().StringVarP(&password, "password", "p", "arista", "password for a gnmi resource") + deviceCreateCmd.Flags().StringVarP(&username, "username", "u", "", "username for a gnmi resource") + deviceCreateCmd.Flags().StringVarP(&password, "password", "p", "", "password for a gnmi resource") } diff --git a/cli/cmd/deviceSet.go b/cli/cmd/deviceSet.go index 15806d356c22f43b5719685abe7d30baf2e3e041..baaae3419af7b1d27184396830c2c1bc65c662e1 100644 --- a/cli/cmd/deviceSet.go +++ b/cli/cmd/deviceSet.go @@ -105,6 +105,11 @@ To enable replacing behaviour (destructive!), set the --replace flag."`, } return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + replace, forcePush, file = false, false, "" + }, } func fileContentToString(path string) (string, error) { diff --git a/cli/cmd/login.go b/cli/cmd/login.go index 77e655f81c99ef4c5b8536cf74985ffb69eb7997..0596b6852f351fdfbe35a97bae8a0a5abef74280 100644 --- a/cli/cmd/login.go +++ b/cli/cmd/login.go @@ -88,6 +88,11 @@ var loginCmd = &cobra.Command{ return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + nbUserName, nbUserPwd, controllerAPIEndpoint = "", "", viper.GetString("controllerAPIEndpoint") + }, } func init() { diff --git a/cli/cmd/logout.go b/cli/cmd/logout.go index a8268b764b87dafee818a590597cdc4ed4096781..2aeb75e9abafa490aed3ea3d27b3f6d5c05c018f 100644 --- a/cli/cmd/logout.go +++ b/cli/cmd/logout.go @@ -68,6 +68,11 @@ var logoutCmd = &cobra.Command{ return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + nbUserName = "" + }, } func init() { diff --git a/cli/cmd/pndCreate.go b/cli/cmd/pndCreate.go index a2859604d68fe38b34a252aa1d56b5b9354346a2..4ff4f8c378c793db7eaaf4a01059673ccd1c165b 100644 --- a/cli/cmd/pndCreate.go +++ b/cli/cmd/pndCreate.go @@ -66,6 +66,11 @@ passed using parameters.`, return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + pndName, pndDescription, pndDefaultSbi = "", "", "openconfig" + }, } var pndName string diff --git a/cli/cmd/userCreate.go b/cli/cmd/userCreate.go index bd0b8788872f9a88bbcf083d967a7f9b8cbb15c8..8246187e14801a449082564858fcf8e4a5c132a9 100644 --- a/cli/cmd/userCreate.go +++ b/cli/cmd/userCreate.go @@ -70,6 +70,11 @@ var userCreateCmd = &cobra.Command{ return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + nbUserName, nbUserPwd, nbUserRole = "", "", "" + }, } var nbUserRole string diff --git a/cli/cmd/userDelete.go b/cli/cmd/userDelete.go index c8bfb21519f4f5f303ab5ec43a0c5b880437e090..5efe1f925c97b064f7dffd80be96c5891b9c5cf4 100644 --- a/cli/cmd/userDelete.go +++ b/cli/cmd/userDelete.go @@ -58,6 +58,11 @@ var userDeleteCmd = &cobra.Command{ return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + nbUserName = "" + }, } func init() { diff --git a/cli/cmd/userGet.go b/cli/cmd/userGet.go index 1a487a3a7f02a2aa275f479ca064210ee89fbe38..5fcacd84e1457a3e64c3b23eb3fa8378c78ea945 100644 --- a/cli/cmd/userGet.go +++ b/cli/cmd/userGet.go @@ -63,6 +63,11 @@ var userGetCmd = &cobra.Command{ return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + nbUserName = "" + }, } func init() { diff --git a/cli/cmd/userUpdate.go b/cli/cmd/userUpdate.go index 7288d9e4d323ed3a5cf78cd7c4b59a6a0ca5f275..b9a2bd1ff509e4331620d4796698b69658dba2c2 100644 --- a/cli/cmd/userUpdate.go +++ b/cli/cmd/userUpdate.go @@ -71,6 +71,11 @@ var userUpdateCmd = &cobra.Command{ return nil }, + PostRun: func(cmd *cobra.Command, args []string) { + // Necessary for prompt mode. The flag variables have to be resetted, + // since in prompt mode the program keeps running. + nbUserID, nbUserName, nbUserPwd, nbUserRole = "", "", "", "" + }, } var nbUserID string