diff options
| author | 2026-01-10 21:29:32 +0100 | |
|---|---|---|
| committer | 2026-01-10 21:29:32 +0100 | |
| commit | 99375a7b664750c1288558f1d5c02b833a2e083c (patch) | |
| tree | 52295802e250d8dacc82bdc49740e3a2c41f5253 /main.c | |
| parent | New file xs_list_tools.h. (diff) | |
| download | snac2-99375a7b664750c1288558f1d5c02b833a2e083c.tar.gz snac2-99375a7b664750c1288558f1d5c02b833a2e083c.tar.xz snac2-99375a7b664750c1288558f1d5c02b833a2e083c.zip | |
New command-line option top_ten.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 21 |
1 files changed, 20 insertions, 1 deletions
| @@ -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 | ||