aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-04-18 08:44:47 +0200
committerdefault <nobody@localhost>2025-04-18 08:44:47 +0200
commitd11d03787fa5f45926859e780d9c8c0bf56bf5ee (patch)
tree3105984fc9bf2ba19dd148721251bfa00cea170e /main.c
parent8fbc8a3e14da59b9aa0640e5cc70d7556cf27c8d (diff)
New command-line options 'lists' and 'list_members'.
Diffstat (limited to 'main.c')
-rw-r--r--main.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/main.c b/main.c
index 3cd4524..7632032 100644
--- a/main.c
+++ b/main.c
@@ -59,6 +59,8 @@ int usage(void)
printf("import_csv {basedir} {uid} Imports data from CSV files\n");
printf("import_list {basedir} {uid} {file} Imports a Mastodon CSV list file\n");
printf("import_block_list {basedir} {uid} {file} Imports a Mastodon CSV block list file\n");
+ printf("lists {basedir} {uid} Returns the names of the lists created by the user\n");
+ printf("list_members {basedir} {uid} {name} Returns the list of accounts inside a list\n");
return 1;
}
@@ -282,9 +284,41 @@ int main(int argc, char *argv[])
return migrate_account(&snac);
}
+ if (strcmp(cmd, "lists") == 0) { /** **/
+ xs *lol = list_maint(&snac, NULL, 0);
+ const xs_list *l;
+
+ xs_list_foreach(lol, l) {
+ printf("%s (%s)\n", xs_list_get(l, 1), xs_list_get(l, 0));
+ }
+
+ return 0;
+ }
+
if ((url = GET_ARGV()) == NULL)
return usage();
+ if (strcmp(cmd, "list_members") == 0) { /** **/
+ xs *lid = list_maint(&snac, url, 4);
+
+ if (lid != NULL) {
+ xs *lcont = list_content(&snac, lid, NULL, 0);
+ const char *md5;
+
+ xs_list_foreach(lcont, md5) {
+ xs *actor = NULL;
+
+ if (valid_status(object_get_by_md5(md5, &actor))) {
+ printf("%s (%s)\n", xs_dict_get(actor, "id"), xs_dict_get_def(actor, "preferredUsername", ""));
+ }
+ }
+ }
+ else
+ fprintf(stderr, "Cannot find list named '%s'\n", url);
+
+ return 0;
+ }
+
if (strcmp(cmd, "alias") == 0) { /** **/
xs *actor = NULL;
xs *uid = NULL;