2019-05-21 22:31:04 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"git.sr.ht/~sircmpwn/aerc/widgets"
|
2019-06-05 00:05:46 +02:00
|
|
|
"git.sr.ht/~sircmpwn/getopt"
|
2019-05-21 22:31:04 +02:00
|
|
|
)
|
|
|
|
|
2019-06-27 19:33:11 +02:00
|
|
|
type NewAccount struct{}
|
|
|
|
|
2019-05-21 22:31:04 +02:00
|
|
|
func init() {
|
2019-06-27 19:33:11 +02:00
|
|
|
register(NewAccount{})
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (NewAccount) Aliases() []string {
|
2019-06-27 19:33:11 +02:00
|
|
|
return []string{"new-account"}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +02:00
|
|
|
func (NewAccount) Complete(aerc *widgets.Aerc, args []string) []string {
|
2019-06-27 19:33:11 +02:00
|
|
|
return nil
|
2019-05-21 22:31:04 +02:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:34:03 +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")
|
2019-06-05 00:05:46 +02:00
|
|
|
if err != nil {
|
|
|
|
return errors.New("Usage: new-account [-t]")
|
2019-05-21 22:31:04 +02:00
|
|
|
}
|
2019-05-22 16:40:08 +02:00
|
|
|
wizard := widgets.NewAccountWizard(aerc.Config(), aerc)
|
2019-06-05 00:05:46 +02:00
|
|
|
for _, opt := range opts {
|
|
|
|
switch opt.Option {
|
|
|
|
case 't':
|
|
|
|
wizard.ConfigureTemporaryAccount(true)
|
|
|
|
}
|
|
|
|
}
|
2019-05-21 22:31:04 +02:00
|
|
|
aerc.NewTab(wizard, "New account")
|
|
|
|
return nil
|
|
|
|
}
|