diff options
author | Robin Jarry <robin@jarry.cc> | 2021-11-01 21:38:26 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2021-11-05 10:45:31 +0100 |
commit | e41ed82cf3dbb4a1152a562ab754a9dc4a6c57b3 (patch) | |
tree | 098cc67f60eb3e0d7c16ad82adb4c988aa08c61e /commands/account | |
parent | 20752df89c3bef0aca23493bfe8a668b93db9947 (diff) | |
download | aerc-e41ed82cf3dbb4a1152a562ab754a9dc4a6c57b3.tar.gz |
imap: add manual {dis,}connect support
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/account')
-rw-r--r-- | commands/account/connection.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/commands/account/connection.go b/commands/account/connection.go new file mode 100644 index 00000000..a87993b6 --- /dev/null +++ b/commands/account/connection.go @@ -0,0 +1,37 @@ +package account + +import ( + "errors" + + "git.sr.ht/~rjarry/aerc/widgets" + "git.sr.ht/~rjarry/aerc/worker/types" +) + +type Connection struct{} + +func init() { + register(Connection{}) +} + +func (Connection) Aliases() []string { + return []string{"connect", "disconnect"} +} + +func (Connection) Complete(aerc *widgets.Aerc, args []string) []string { + return nil +} + +func (Connection) Execute(aerc *widgets.Aerc, args []string) error { + acct := aerc.SelectedAccount() + if acct == nil { + return errors.New("No account selected") + } + if args[0] == "connect" { + acct.Worker().PostAction(&types.Connect{}, nil) + acct.SetStatus("Connecting...") + } else { + acct.Worker().PostAction(&types.Disconnect{}, nil) + acct.SetStatus("Disconnecting...") + } + return nil +} |