package cli import ( "fmt" "io" "git.dcglab.co.uk/steve/emcli/internal/store" ) // accountShow renders one account's configuration. The password is never shown. func accountShow(st *store.Store, rest []string, out, errOut io.Writer) int { if len(rest) == 0 { fmt.Fprintln(errOut, "usage: emcli account show ") return 2 } if len(rest) > 1 { fmt.Fprintf(errOut, "unexpected argument %q\n", rest[1]) return 2 } a, err := st.GetAccount(rest[0]) if err != nil { fmt.Fprintf(errOut, "show: %v\n", err) return 1 } onOff := func(b bool) string { if b { return "enabled" } return "disabled" } smtp := "-" if a.SMTPHost != "" { smtp = fmt.Sprintf("%s:%d (%s)", a.SMTPHost, a.SMTPPort, a.SMTPSecurity) } subj := a.SubjectRegex if subj == "" { subj = "(none)" } fmt.Fprintf(out, "name: %s\n", a.Name) fmt.Fprintf(out, "mode: %s\n", a.Mode) fmt.Fprintf(out, "imap: %s:%d (%s)\n", a.IMAPHost, a.IMAPPort, a.IMAPSecurity) fmt.Fprintf(out, "smtp: %s\n", smtp) fmt.Fprintf(out, "username: %s\n", a.Username) fmt.Fprintf(out, "send-from: %s\n", a.SendFrom()) fmt.Fprintf(out, "subject filter: %s\n", subj) fmt.Fprintf(out, "inbound whitelist: %s\n", onOff(a.WhitelistInEnabled)) fmt.Fprintf(out, "outbound whitelist:%s\n", onOff(a.WhitelistOutEnabled)) return 0 }