From 99375a7b664750c1288558f1d5c02b833a2e083c Mon Sep 17 00:00:00 2001 From: grunfink Date: Sat, 10 Jan 2026 21:29:32 +0100 Subject: New command-line option top_ten. --- main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 29a8a51..4ba9796 100644 --- a/main.c +++ b/main.c @@ -76,7 +76,8 @@ int usage(const char *cmd) "list_create {basedir} {uid} {name} Creates a new list\n" "list_remove {basedir} {uid} {name} Removes an existing list\n" "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n" - "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n"; + "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n" + "top_ten {basedir} {uid} [{N}] Prints the most popular posts\n"; if (cmd == NULL) printf("%s", cmds); @@ -350,6 +351,24 @@ int main(int argc, char *argv[]) return 0; } + if (strcmp(cmd, "top_ten") == 0) { /** **/ + int count = 10; + const char *n = GET_ARGV(); + if (xs_is_string(n)) + count = atoi(n); + + xs *l = user_top_ten(&snac, count); + const xs_list *i; + + xs_list_foreach(l, i) { + printf("%s %ld★ %ld↺\n", xs_list_get(i, 0), + xs_number_get_l(xs_list_get(i, 1)), + xs_number_get_l(xs_list_get(i, 2))); + } + + return 0; + } + if ((url = GET_ARGV()) == NULL) return usage(cmd); -- cgit v1.2.3