| 788 | } |
| 789 | |
| 790 | func fetchUpdateUserDetails(inputs *userInput, current *management.User) *management.User { |
| 791 | user := &management.User{} |
| 792 | |
| 793 | switch *current.Connection { |
| 794 | case "email": |
| 795 | if len(inputs.email) != 0 { |
| 796 | user.Email = &inputs.email |
| 797 | } |
| 798 | case "sms": |
| 799 | if len(inputs.phoneNumber) != 0 { |
| 800 | user.PhoneNumber = &inputs.phoneNumber |
| 801 | } |
| 802 | default: |
| 803 | if len(inputs.email) != 0 && current.Email != &inputs.email { |
| 804 | user.Email = &inputs.email |
| 805 | } |
| 806 | |
| 807 | if len(inputs.password) != 0 { |
| 808 | user.Password = &inputs.password |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | if len(inputs.name) == 0 { |
| 813 | user.Name = current.Name |
| 814 | } else { |
| 815 | user.Name = &inputs.name |
| 816 | } |
| 817 | |
| 818 | if len(inputs.connectionName) == 0 { |
| 819 | user.Connection = current.Connection |
| 820 | } else { |
| 821 | user.Connection = &inputs.connectionName |
| 822 | } |
| 823 | |
| 824 | return user |
| 825 | } |
| 826 | |
| 827 | func openUserCmd(cli *cli) *cobra.Command { |
| 828 | var inputs struct { |