Skip to content

Commit

Permalink
Fix the paging & refactor a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseWeinstein committed Dec 27, 2022
1 parent d616a8f commit 6a541c7
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/tootstream/toot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ def following(mastodon, rest):
# request more from server if first call doesn't get full list
# TODO: optional username/userid to show another user's following?
user = mastodon.account_verify_credentials()
users = mastodon.account_following(user['id'])
users = mastodon.fetch_remaining(mastodon.account_following(user['id']))
if not users:
cprint(" You aren't following anyone", fg('red'))
else:
Expand Down Expand Up @@ -2140,7 +2140,7 @@ def listunion(mastodon, rest):
return
if items[1] == "[following]":
user = mastodon.account_verify_credentials()
list_accounts = mastodon.account_following(user['id'])
list_accounts = mastodon.fetch_remaining(mastodon.account_following(user['id']))
else:
union_list_id = get_list_id(mastodon, items[1])
if not union_list_id:
Expand Down Expand Up @@ -2226,17 +2226,7 @@ def authenticated(mastodon):
return True


CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--instance', '-i', metavar='<string>',
help='Hostname of the instance to connect')
@click.option('--config', '-c', metavar='<file>',
type=click.Path(exists=False, readable=True),
default='~/.config/tootstream/tootstream.conf',
help='Location of alternate configuration file to load')
@click.option('--profile', '-P', metavar='<profile>', default='default',
help='Name of profile for saved credentials (default)')
def main(instance, config, profile):
def get_mastodon(instance, config, profile):
configpath = os.path.expanduser(config)
if os.path.isfile(configpath) and not os.access(configpath, os.W_OK):
# warn the user before they're asked for input
Expand Down Expand Up @@ -2278,6 +2268,22 @@ def main(instance, config, profile):
}

save_config(configpath, config)
return (mastodon, profile)


CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--instance', '-i', metavar='<string>',
help='Hostname of the instance to connect')
@click.option('--config', '-c', metavar='<file>',
type=click.Path(exists=False, readable=True),
default='~/.config/tootstream/tootstream.conf',
help='Location of alternate configuration file to load')
@click.option('--profile', '-P', metavar='<profile>', default='default',
help='Name of profile for saved credentials (default)')
def main(instance, config, profile):
print(f'## {instance}, {config}, {profile}')
mastodon, profile = get_mastodon(instance, config, profile)

def say_error(a, b): return cprint("Invalid command. Use 'help' for a list of commands.",
fg('white') + bg('red'))
Expand Down

0 comments on commit 6a541c7

Please sign in to comment.