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:
Mechiel Lukkien
2025-04-16 19:59:20 +02:00
parent 31c22618f5
commit 1b2b152cb5
4 changed files with 58 additions and 1 deletions

21
ctl.go
View File

@ -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"