mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-29 04:35:54 -04:00
Replace tags_* commands with a group
This commit is contained in:
parent
875bf2d86a
commit
9098279d40
@ -2,32 +2,68 @@ import click
|
|||||||
|
|
||||||
from toot import api
|
from toot import api
|
||||||
from toot.cli.base import cli, pass_context, Context
|
from toot.cli.base import cli, pass_context, Context
|
||||||
from toot.output import print_tag_list
|
from toot.output import print_tag_list, print_warning
|
||||||
|
|
||||||
|
|
||||||
@cli.command(name="tags_followed")
|
@cli.group(invoke_without_command=True)
|
||||||
@pass_context
|
@click.pass_context
|
||||||
def tags_followed(ctx: Context):
|
def tags(ctx: click.Context):
|
||||||
"""List hashtags you follow"""
|
"""List, follow, and unfollow tags
|
||||||
response = api.followed_tags(ctx.app, ctx.user)
|
|
||||||
|
When invoked without a command, lists followed tags."""
|
||||||
|
if ctx.invoked_subcommand is None:
|
||||||
|
response = api.followed_tags(ctx.obj.app, ctx.obj.user)
|
||||||
print_tag_list(response)
|
print_tag_list(response)
|
||||||
|
|
||||||
|
|
||||||
@cli.command(name="tags_follow")
|
@tags.command()
|
||||||
@click.argument("tag")
|
@click.argument("tag")
|
||||||
@pass_context
|
@pass_context
|
||||||
def tags_follow(ctx: Context, tag: str):
|
def follow(ctx: Context, tag: str):
|
||||||
"""Follow a hashtag"""
|
"""Follow a hashtag"""
|
||||||
tag = tag.lstrip("#")
|
tag = tag.lstrip("#")
|
||||||
api.follow_tag(ctx.app, ctx.user, tag)
|
api.follow_tag(ctx.app, ctx.user, tag)
|
||||||
click.secho(f"✓ You are now following #{tag}", fg="green")
|
click.secho(f"✓ You are now following #{tag}", fg="green")
|
||||||
|
|
||||||
|
|
||||||
@cli.command(name="tags_unfollow")
|
@tags.command()
|
||||||
@click.argument("tag")
|
@click.argument("tag")
|
||||||
@pass_context
|
@pass_context
|
||||||
def tags_unfollow(ctx: Context, tag: str):
|
def unfollow(ctx: Context, tag: str):
|
||||||
"""Unfollow a hashtag"""
|
"""Unfollow a hashtag"""
|
||||||
tag = tag.lstrip("#")
|
tag = tag.lstrip("#")
|
||||||
api.unfollow_tag(ctx.app, ctx.user, tag)
|
api.unfollow_tag(ctx.app, ctx.user, tag)
|
||||||
click.secho(f"✓ You are no longer following #{tag}", fg="green")
|
click.secho(f"✓ You are no longer following #{tag}", fg="green")
|
||||||
|
|
||||||
|
|
||||||
|
# -- Deprecated commands -------------------------------------------------------
|
||||||
|
|
||||||
|
@cli.command(name="tags_followed", hidden=True)
|
||||||
|
@pass_context
|
||||||
|
def tags_followed(ctx: Context):
|
||||||
|
"""List hashtags you follow"""
|
||||||
|
print_warning("`toot tags_followed` is deprecated in favour of `toot tags`")
|
||||||
|
response = api.followed_tags(ctx.app, ctx.user)
|
||||||
|
print_tag_list(response)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command(name="tags_follow", hidden=True)
|
||||||
|
@click.argument("tag")
|
||||||
|
@pass_context
|
||||||
|
def tags_follow(ctx: Context, tag: str):
|
||||||
|
"""Follow a hashtag"""
|
||||||
|
print_warning("`toot tags_follow` is deprecated in favour of `toot tags follow`")
|
||||||
|
tag = tag.lstrip("#")
|
||||||
|
api.follow_tag(ctx.app, ctx.user, tag)
|
||||||
|
click.secho(f"✓ You are now following #{tag}", fg="green")
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command(name="tags_unfollow", hidden=True)
|
||||||
|
@click.argument("tag")
|
||||||
|
@pass_context
|
||||||
|
def tags_unfollow(ctx: Context, tag: str):
|
||||||
|
"""Unfollow a hashtag"""
|
||||||
|
print_warning("`toot tags_unfollow` is deprecated in favour of `toot tags unfollow`")
|
||||||
|
tag = tag.lstrip("#")
|
||||||
|
api.unfollow_tag(ctx.app, ctx.user, tag)
|
||||||
|
click.secho(f"✓ You are no longer following #{tag}", fg="green")
|
||||||
|
Loading…
Reference in New Issue
Block a user