def following(ctx, check, timeout, porcelain): """Return the list of sources you’re following.""" sources = ctx.obj['conf'].following if check: sources = get_remote_status(sources, timeout) for (source, status) in sources: click.echo(style_source_with_status(source, status, porcelain)) else: sources = sorted(sources, key=lambda source: source.nick) for source in sources: click.echo(style_source(source, porcelain))
def follow(ctx, nick, url, force): """Add a new source to your followings.""" source = Source(nick, url) sources = ctx.obj['conf'].following if not force: if source.nick in (source.nick for source in sources): click.confirm("➤ You’re already following {0}. Overwrite?".format( click.style(source.nick, bold=True)), default=False, abort=True) _, status = get_remote_status([source])[0] if status != 200: click.confirm("➤ The feed of {0} at {1} is not available. Follow anyway?".format( click.style(source.nick, bold=True), click.style(source.url, bold=True)), default=False, abort=True) ctx.obj['conf'].add_source(source) click.echo("✓ You’re now following {0}.".format( click.style(source.nick, bold=True)))