From d11d03787fa5f45926859e780d9c8c0bf56bf5ee Mon Sep 17 00:00:00 2001 From: default Date: Fri, 18 Apr 2025 08:44:47 +0200 Subject: New command-line options 'lists' and 'list_members'. --- main.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'main.c') 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; -- cgit v1.2.3