diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 25 |
1 files changed, 22 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* snac - A simple, minimalistic ActivityPub instance */ | 1 | /* snac - A simple, minimalistic ActivityPub instance */ |
| 2 | /* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ | 2 | /* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ |
| 3 | 3 | ||
| 4 | #include "xs.h" | 4 | #include "xs.h" |
| 5 | #include "xs_io.h" | 5 | #include "xs_io.h" |
| @@ -18,7 +18,7 @@ | |||
| 18 | int usage(const char *cmd) | 18 | int usage(const char *cmd) |
| 19 | { | 19 | { |
| 20 | printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n"); | 20 | printf("snac " VERSION " - A simple, minimalistic ActivityPub instance\n"); |
| 21 | printf("Copyright (c) 2022 - 2025 grunfink et al. / MIT license\n"); | 21 | printf("Copyright (c) 2022 - 2026 grunfink et al. / MIT license\n"); |
| 22 | printf("\n"); | 22 | printf("\n"); |
| 23 | 23 | ||
| 24 | if (cmd == NULL) { | 24 | if (cmd == NULL) { |
| @@ -76,7 +76,8 @@ int usage(const char *cmd) | |||
| 76 | "list_create {basedir} {uid} {name} Creates a new list\n" | 76 | "list_create {basedir} {uid} {name} Creates a new list\n" |
| 77 | "list_remove {basedir} {uid} {name} Removes an existing list\n" | 77 | "list_remove {basedir} {uid} {name} Removes an existing list\n" |
| 78 | "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n" | 78 | "list_add {basedir} {uid} {name} {acct} Adds an account (@user@host or actor url) to a list\n" |
| 79 | "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n"; | 79 | "list_del {basedir} {uid} {name} {actor} Deletes an actor URL from a list\n" |
| 80 | "top_ten {basedir} {uid} [{N}] Prints the most popular posts\n"; | ||
| 80 | 81 | ||
| 81 | if (cmd == NULL) | 82 | if (cmd == NULL) |
| 82 | printf("%s", cmds); | 83 | printf("%s", cmds); |
| @@ -350,6 +351,24 @@ int main(int argc, char *argv[]) | |||
| 350 | return 0; | 351 | return 0; |
| 351 | } | 352 | } |
| 352 | 353 | ||
| 354 | if (strcmp(cmd, "top_ten") == 0) { /** **/ | ||
| 355 | int count = 10; | ||
| 356 | const char *n = GET_ARGV(); | ||
| 357 | if (xs_is_string(n)) | ||
| 358 | count = atoi(n); | ||
| 359 | |||
| 360 | xs *l = user_top_ten(&snac, count); | ||
| 361 | const xs_list *i; | ||
| 362 | |||
| 363 | xs_list_foreach(l, i) { | ||
| 364 | printf("%s %ld★ %ld↺\n", xs_list_get(i, 0), | ||
| 365 | xs_number_get_l(xs_list_get(i, 1)), | ||
| 366 | xs_number_get_l(xs_list_get(i, 2))); | ||
| 367 | } | ||
| 368 | |||
| 369 | return 0; | ||
| 370 | } | ||
| 371 | |||
| 353 | if ((url = GET_ARGV()) == NULL) | 372 | if ((url = GET_ARGV()) == NULL) |
| 354 | return usage(cmd); | 373 | return usage(cmd); |
| 355 | 374 | ||