summaryrefslogtreecommitdiff
path: root/brisket.hy
diff options
context:
space:
mode:
Diffstat (limited to 'brisket.hy')
-rw-r--r--brisket.hy37
1 files changed, 19 insertions, 18 deletions
diff --git a/brisket.hy b/brisket.hy
index 7b95166..e18732a 100644
--- a/brisket.hy
+++ b/brisket.hy
@@ -36,8 +36,8 @@
(setv *config-path* (expanduser "~/.config/brisket/config.ini"))
(setv *recognized-commands* ["describe-group"
"help"
- "list-group"
"list-groups"
+ "list-posts"
"version"])
(defn help [&rest args]
@@ -93,6 +93,24 @@ usage: describe-groups [pattern]"
(err "ERROR: Group does not have a description.")
(print description))))
+(defn list-posts [session &rest args]
+ "List posts in the given group.
+
+usage: describe-group [group]"
+ (when (< (len args) 1)
+ (err "usage: describe-group [group]")
+ (return))
+ (let [res (.group session (first args))
+ first-post (nth res 2)
+ last-post (nth res 3)
+ overviews (second (.over session [first-post last-post]))]
+ (for [[article-id overview] overviews]
+ (print (.format "{}: {} by {} on {}"
+ article-id
+ (.get overview "subject")
+ (.get overview "from")
+ (.get overview "date"))))))
+
(defn make-config []
"Create a default configuration file.
@@ -186,20 +204,3 @@ The lookup order is:
;; Otherwise, pull the function out of the global namespace.
(let [handler (get (globals) (.replace command "-" "_"))]
(handler session #* (drop 2 argv)))))])))
-
-;; # To-be-converted Python
-;;
-;; def list_group(n, *args):
-;; if len(args) < 1:
-;; err("usage: list-group [group]")
-;; return
-;;
-;; _, _, first, last, _ = n.group(args[0])
-;; _, overviews = n.over((first, last))
-;;
-;; for article_num, overview in overviews:
-;; print("\"{}\" by {} on {}".format(
-;; overview.get("subject"),
-;; overview.get("from"),
-;; overview.get("date"),
-;; ))