Show account wizard if no accounts configured
This commit is contained in:
parent
1a45b793c7
commit
9b19e3ad05
4 changed files with 12 additions and 12 deletions
|
@ -100,7 +100,8 @@ func mapName(raw string) string {
|
|||
func loadAccountConfig(path string) ([]AccountConfig, error) {
|
||||
file, err := ini.Load(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// No config triggers account configuration wizard
|
||||
return nil, nil
|
||||
}
|
||||
file.NameMapper = mapName
|
||||
|
||||
|
@ -153,10 +154,6 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
|
|||
|
||||
accounts = append(accounts, account)
|
||||
}
|
||||
if len(accounts) == 0 {
|
||||
err = errors.New("No accounts configured in accounts.conf")
|
||||
return nil, err
|
||||
}
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
|
@ -359,7 +356,7 @@ func LoadConfig(root *string) (*AercConfig, error) {
|
|||
func checkConfigPerms(filename string) error {
|
||||
info, err := os.Stat(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil // disregard absent files
|
||||
}
|
||||
perms := info.Mode().Perm()
|
||||
goPerms := perms >> 3
|
||||
|
|
|
@ -66,7 +66,7 @@ func (ti *TextInput) Draw(ctx *Context) {
|
|||
ctx.Printf(0, 0, tcell.StyleDefault, "%s%s", ti.prompt, string(ti.text))
|
||||
}
|
||||
cells := runewidth.StringWidth(string(ti.text[:ti.index]) + ti.prompt)
|
||||
if cells != ti.cells && ti.focus {
|
||||
if ti.focus {
|
||||
ctx.SetCursor(cells, 0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,8 +356,8 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
|
|||
"To add another account in the future, run ':new-account'."))
|
||||
selecter = newSelecter([]string{
|
||||
"Previous",
|
||||
"Finish",
|
||||
"Finish & open tutorial",
|
||||
"Finish",
|
||||
}, 1).OnChoose(func(option string) {
|
||||
switch option {
|
||||
case "Previous":
|
||||
|
@ -436,11 +436,8 @@ func (wizard *AccountWizard) finish(tutorial bool) {
|
|||
}
|
||||
|
||||
file, err := ini.Load(accountsConf)
|
||||
if err == os.ErrNotExist {
|
||||
if err != nil {
|
||||
file = ini.Empty()
|
||||
} else if err != nil {
|
||||
wizard.errorFor(nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
var sec *ini.Section
|
||||
|
|
|
@ -62,6 +62,12 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger,
|
|||
tabs.Add(view, acct.Name)
|
||||
}
|
||||
|
||||
if len(conf.Accounts) == 0 {
|
||||
wizard := NewAccountWizard(aerc.Config(), aerc)
|
||||
wizard.Focus(true)
|
||||
aerc.NewTab(wizard, "New account")
|
||||
}
|
||||
|
||||
return aerc
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue