consistent newlines in errx

This commit is contained in:
Ted Unangst 2023-08-28 16:08:29 -04:00
parent aad5243bb1
commit a4817e149b
1 changed files with 15 additions and 15 deletions

30
main.go
View File

@ -65,7 +65,7 @@ func reexecArgs(cmd string) []string {
var elog, ilog, dlog *golog.Logger var elog, ilog, dlog *golog.Logger
func errx(msg string, args ...interface{}) { func errx(msg string, args ...interface{}) {
fmt.Fprintf(os.Stderr, msg, args...) fmt.Fprintf(os.Stderr, msg+"\n", args...)
os.Exit(1) os.Exit(1)
} }
@ -160,55 +160,55 @@ func main() {
adduser() adduser()
case "deluser": case "deluser":
if len(args) < 2 { if len(args) < 2 {
errx("usage: honk deluser username\n") errx("usage: honk deluser username")
} }
deluser(args[1]) deluser(args[1])
case "chpass": case "chpass":
if len(args) < 2 { if len(args) < 2 {
errx("usage: honk chpass username\n") errx("usage: honk chpass username")
} }
chpass(args[1]) chpass(args[1])
case "follow": case "follow":
if len(args) < 3 { if len(args) < 3 {
errx("usage: honk follow username url\n") errx("usage: honk follow username url")
} }
user, err := butwhatabout(args[1]) user, err := butwhatabout(args[1])
if err != nil { if err != nil {
errx("user %s not found\n", args[1]) errx("user %s not found", args[1])
} }
var meta HonkerMeta var meta HonkerMeta
mj, _ := jsonify(&meta) mj, _ := jsonify(&meta)
honkerid, err := savehonker(user, args[2], "", "presub", "", mj) honkerid, err := savehonker(user, args[2], "", "presub", "", mj)
if err != nil { if err != nil {
errx("had some trouble with that: %s\n", err) errx("had some trouble with that: %s", err)
} }
followyou(user, honkerid, true) followyou(user, honkerid, true)
case "unfollow": case "unfollow":
if len(args) < 3 { if len(args) < 3 {
errx("usage: honk unfollow username url\n") errx("usage: honk unfollow username url")
} }
user, err := butwhatabout(args[1]) user, err := butwhatabout(args[1])
if err != nil { if err != nil {
errx("user not found\n") errx("user not found")
} }
row := db.QueryRow("select honkerid from honkers where xid = ? and userid = ? and flavor in ('sub')", args[2], user.ID) row := db.QueryRow("select honkerid from honkers where xid = ? and userid = ? and flavor in ('sub')", args[2], user.ID)
var honkerid int64 var honkerid int64
err = row.Scan(&honkerid) err = row.Scan(&honkerid)
if err != nil { if err != nil {
errx("sorry couldn't find them\n") errx("sorry couldn't find them")
} }
unfollowyou(user, honkerid, true) unfollowyou(user, honkerid, true)
case "sendmsg": case "sendmsg":
if len(args) < 4 { if len(args) < 4 {
errx("usage: honk send username filename rcpt\n") errx("usage: honk send username filename rcpt")
} }
user, err := butwhatabout(args[1]) user, err := butwhatabout(args[1])
if err != nil { if err != nil {
errx("user %s not found\n", args[1]) errx("user %s not found", args[1])
} }
data, err := os.ReadFile(args[2]) data, err := os.ReadFile(args[2])
if err != nil { if err != nil {
errx("can't read file: %s\n", err) errx("can't read file: %s", err)
} }
deliverate(user.ID, args[3], data) deliverate(user.ID, args[3], data)
case "cleanup": case "cleanup":
@ -219,19 +219,19 @@ func main() {
cleanupdb(arg) cleanupdb(arg)
case "unplug": case "unplug":
if len(args) < 2 { if len(args) < 2 {
errx("usage: honk unplug servername\n") errx("usage: honk unplug servername")
} }
name := args[1] name := args[1]
unplugserver(name) unplugserver(name)
case "backup": case "backup":
if len(args) < 2 { if len(args) < 2 {
errx("usage: honk backup dirname\n") errx("usage: honk backup dirname")
} }
name := args[1] name := args[1]
svalbard(name) svalbard(name)
case "ping": case "ping":
if len(args) < 3 { if len(args) < 3 {
errx("usage: honk ping (from username) (to username or url)\n") errx("usage: honk ping (from username) (to username or url)")
} }
name := args[1] name := args[1]
targ := args[2] targ := args[2]