aerc/commands/new-account.go

38 lines
722 B
Go
Raw Normal View History

2019-05-21 22:31:04 +02:00
package commands
import (
"errors"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
2019-05-21 22:31:04 +02:00
)
type NewAccount struct{}
2019-05-21 22:31:04 +02:00
func init() {
register(NewAccount{})
}
func (NewAccount) Aliases() []string {
return []string{"new-account"}
}
func (NewAccount) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
2019-05-21 22:31:04 +02:00
}
func (NewAccount) Execute(aerc *widgets.Aerc, args []string) error {
2019-06-10 01:14:56 +02:00
opts, _, err := getopt.Getopts(args, "t")
if err != nil {
return errors.New("Usage: new-account [-t]")
2019-05-21 22:31:04 +02:00
}
wizard := widgets.NewAccountWizard(aerc.Config(), aerc)
for _, opt := range opts {
if opt.Option == 't' {
wizard.ConfigureTemporaryAccount(true)
}
}
2019-05-21 22:31:04 +02:00
aerc.NewTab(wizard, "New account")
return nil
}