mirror of
https://github.com/mjl-/mox.git
synced 2025-07-19 00:06:37 +03:00
add "mox config account list", printing all accounts and whether they are disabled
based on question from wisse on slack
This commit is contained in:
21
ctl.go
21
ctl.go
@ -15,6 +15,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -33,7 +34,6 @@ import (
|
||||
"github.com/mjl-/mox/smtp"
|
||||
"github.com/mjl-/mox/store"
|
||||
"github.com/mjl-/mox/webapi"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// ctl represents a connection to the ctl unix domain socket of a running mox instance.
|
||||
@ -1056,6 +1056,25 @@ func servectlcmd(ctx context.Context, xctl *ctl, cid int64, shutdown func()) {
|
||||
xctl.xcheck(err, "removing account")
|
||||
xctl.xwriteok()
|
||||
|
||||
case "accountlist":
|
||||
/* protocol:
|
||||
> "accountlist"
|
||||
< "ok" or error
|
||||
< stream
|
||||
*/
|
||||
xctl.xwriteok()
|
||||
xw := xctl.writer()
|
||||
all, disabled := mox.Conf.AccountsDisabled()
|
||||
slices.Sort(all)
|
||||
for _, account := range all {
|
||||
var extra string
|
||||
if slices.Contains(disabled, account) {
|
||||
extra += "\t(disabled)"
|
||||
}
|
||||
fmt.Fprintf(xw, "%s%s\n", account, extra)
|
||||
}
|
||||
xw.xclose()
|
||||
|
||||
case "accountdisabled":
|
||||
/* protocol:
|
||||
> "accountdisabled"
|
||||
|
Reference in New Issue
Block a user