about summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
authorJanUlrich <andi@michlaustderaffe.de>2019-06-05 00:05:46 +0200
committerDrew DeVault <sir@cmpwn.com>2019-06-05 09:32:43 -0400
commit0771eaf24c5a1f0e37e0a51fefe1cb5090fa7e2b (patch)
tree382c687f8a10f1c16a6cdc499edd104dc30aea34 /widgets
parent7446a1783050c34eeefa5f5c030cd0cbbb8c70dd (diff)
downloadaerc-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.go36
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{
sr.ht/~sircmpwn/pty v0.0.0-20190330154901-3a43678975a9 github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 github.com/emersion/go-imap v1.0.0-beta.5 github.com/emersion/go-imap-idle v0.0.0-20190519112320-2704abd7050e github.com/emersion/go-message v0.10.3 github.com/emersion/go-sasl v0.0.0-20190517184301-63aa71ca65a3 github.com/emersion/go-smtp v0.11.0 github.com/gdamore/encoding v0.0.0-20151215212835-b23993cbb635 // indirect github.com/gdamore/tcell v1.0.0 github.com/go-ini/ini v1.42.0 github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf github.com/kyoh86/xdg v0.0.0-20171127140545-8db68a8ea76a github.com/lucasb-eyer/go-colorful v0.0.0-20180531031333-d9cec903b20c // indirect github.com/martinlindhe/base36 v0.0.0-20190418230009-7c6542dfbb41 github.com/mattn/go-isatty v0.0.3 github.com/mattn/go-runewidth v0.0.2 github.com/miolini/datacounter v0.0.0-20171104152933-fd4e42a1d5e0 github.com/mitchellh/go-homedir v1.1.0 github.com/riywo/loginshell v0.0.0-20181227004642-c2f4167b2303 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a // indirect github.com/stretchr/testify v1.3.0 golang.org/x/sys v0.0.0-20190516110030-61b9204099cb // indirect gopkg.in/ini.v1 v1.42.0 // indirect )