#!/usr/bin/env python from main import config, SignalAPI from result import is_err import argparse if __name__ == "__main__": parser = argparse.ArgumentParser(description='List all groups') parser.add_argument('-i', "--show-group-ids", action='store_true', help='show group ids') parser.add_argument('--api-url', type=str, default=None, help='API URL') args = parser.parse_args() if args.api_url is not None: config.apiurl = args.api_url api = SignalAPI(config.apiurl, config.number) groups_result = api.get_groups() if is_err(groups_result): print("Error: " + groups_result.unwrap_err()) exit(1) groups = groups_result.unwrap() for group in groups: suffix = "" if api.number in group.admins: suffix = " (admin)" print(group.name + suffix) if args.show_group_ids: print(" id: " + group.id)