feat: added name to the config

drew created

Change summary

config/config.go | 1 +
sender/sender.go | 2 +-
tui/login.go     | 7 ++++++-
3 files changed, 8 insertions(+), 2 deletions(-)

Detailed changes

config/config.go 🔗

@@ -11,6 +11,7 @@ type Config struct {
 	ServiceProvider string `json:"service_provider"`
 	Email           string `json:"email"`
 	Password        string `json:"password"`
+	Name            string `json:"name"`
 }
 
 // configDir returns the path to the configuration directory.

sender/sender.go 🔗

@@ -23,7 +23,7 @@ func SendEmail(cfg *config.Config, to []string, subject, body string) error {
 	}
 
 	auth := smtp.PlainAuth("", cfg.Email, cfg.Password, smtpHost)
-	msg := fmt.Sprintf("From: %s <%s>\r\n", "Some Name", cfg.Email) +
+	msg := fmt.Sprintf("From: %s <%s>\r\n", cfg.Name, cfg.Email) +
 		fmt.Sprintf("To: %s\r\n", to[0]) +
 		fmt.Sprintf("Subject: %s\r\n", subject) +
 		"\r\n" + // An empty line is required between headers and the body.

tui/login.go 🔗

@@ -20,7 +20,7 @@ type loginModel struct {
 
 func initialLoginModel() loginModel {
 	m := loginModel{
-		inputs: make([]textinput.Model, 3),
+		inputs: make([]textinput.Model, 4),
 	}
 
 	var t textinput.Model
@@ -45,6 +45,10 @@ func initialLoginModel() loginModel {
 			t.EchoMode = textinput.EchoPassword
 			t.EchoCharacter = '•'
 			t.CharLimit = 64
+		case 3:
+			t.Placeholder = "Name"
+			t.Prompt = "  "
+			t.CharLimit = 64
 		}
 		m.inputs[i] = t
 	}
@@ -67,6 +71,7 @@ func (m loginModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 					ServiceProvider: m.inputs[0].Value(),
 					Email:           m.inputs[1].Value(),
 					Password:        m.inputs[2].Value(),
+					Name: 		     m.inputs[3].Value(),
 				}
 				if err := config.SaveConfig(m.config); err != nil {
 					m.err = err