about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2020-05-11 02:42:37 -0400
committerBen Morrison <ben@gbmor.dev>2020-05-11 02:42:37 -0400
commit55f346f7aaed303f956ceb95bce8e8aa0a5ea28f (patch)
tree57ce820a928fd2bebf3848294ce137a2e3b93aeb
parenta729136a6a7e36a7b717ee5df615339cb4bde654 (diff)
downloadapi-55f346f7aaed303f956ceb95bce8e8aa0a5ea28f.tar.gz
added plaintext response to user list query
-rw-r--r--users.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/users.go b/users.go
index a40c177..1f8cfb3 100644
--- a/users.go
+++ b/users.go
@@ -15,6 +15,20 @@ func usersQuery(format string) ([]byte, error) {
 	}
 
 	users := strings.Fields(string(ls))
+
+	if format == "plain" {
+		var out []string
+		for _, e := range users {
+			if strings.HasPrefix(e, ".") || strings.HasPrefix(e, "_") {
+				continue
+			}
+			out = append(out, e)
+		}
+		outstring := strings.Join(out, "\n")
+		outstring += "\n"
+		return []byte(outstring), nil
+	}
+
 	out := `{
 	"users": [
 `