diff options
author | JanUlrich <andi@michlaustderaffe.de> | 2019-06-05 00:05:46 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-05 09:32:43 -0400 |
commit | 0771eaf24c5a1f0e37e0a51fefe1cb5090fa7e2b (patch) | |
tree | 382c687f8a10f1c16a6cdc499edd104dc30aea34 /widgets | |
parent | 7446a1783050c34eeefa5f5c030cd0cbbb8c70dd (diff) | |
download | aerc-0771eaf24c5a1f0e37e0a51fefe1cb5090fa7e2b.tar.gz |
Introduce :new-account -t
Adding the [-t] temporary flag to the new-account command - when using -t a newly created account will not be stored into the accounts.conf Issue #134
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account-wizard.go | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index 6cd541e..010d82d 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -39,12 +39,13 @@ const ( type AccountWizard struct { ui.Invalidatable - aerc *Aerc - conf *config.AercConfig - step int - steps []*ui.Grid - focus int - testing bool + aerc *Aerc + conf *config.AercConfig + step int + steps []*ui.Grid + focus int + temporary bool + testing bool // CONFIGURE_BASICS accountName *ui.TextInput email *ui.TextInput @@ -76,6 +77,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { accountName: ui.NewTextInput("").Prompt("> "), aerc: aerc, conf: conf, + temporary: false, copySent: true, email: ui.NewTextInput("").Prompt("> "), fullName: ui.NewTextInput("").Prompt("> "), @@ -378,6 +380,10 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard { return wizard } +func (wizard *AccountWizard) ConfigureTemporaryAccount(temporary bool) { + wizard.temporary = temporary +} + func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) { if d == nil { wizard.aerc.PushStatus(" "+err.Error(), 10*time.Second). @@ -459,14 +465,16 @@ func (wizard *AccountWizard) finish(tutorial bool) { sec.NewKey("copy-to", "Sent") } - f, err := os.OpenFile(accountsConf, os.O_WRONLY|os.O_CREATE, 0600) - if err != nil { - wizard.errorFor(nil, err) - return - } - if _, err = file.WriteTo(f); err != nil { - wizard.errorFor(nil, err) - return + if !wizard.temporary { + f, err := os.OpenFile(accountsConf, os.O_WRONLY|os.O_CREATE, 0600) + if err != nil { + wizard.errorFor(nil, err) + return + } + if _, err = file.WriteTo(f); err != nil { + wizard.errorFor(nil, err) + return + } } account := config.AccountConfig{ |