diff --git a/tests/integration/test_tags.py b/tests/integration/test_tags.py index 491d2c9..bc97f78 100644 --- a/tests/integration/test_tags.py +++ b/tests/integration/test_tags.py @@ -3,7 +3,7 @@ from toot.entities import Tag, from_dict, from_dict_list def test_tags(run, base_url): - result = run(cli.tags) + result = run(cli.tags, "followed") assert result.exit_code == 0 assert result.stdout.strip() == "You're not following any hashtags." @@ -11,7 +11,7 @@ def test_tags(run, base_url): assert result.exit_code == 0 assert result.stdout.strip() == "✓ You are now following #foo" - result = run(cli.tags) + result = run(cli.tags, "followed") assert result.exit_code == 0 assert result.stdout.strip() == f"* #foo\t{base_url}/tags/foo" @@ -19,7 +19,7 @@ def test_tags(run, base_url): assert result.exit_code == 0 assert result.stdout.strip() == "✓ You are now following #bar" - result = run(cli.tags) + result = run(cli.tags, "followed") assert result.exit_code == 0 assert result.stdout.strip() == "\n".join([ f"* #bar\t{base_url}/tags/bar", @@ -30,7 +30,7 @@ def test_tags(run, base_url): assert result.exit_code == 0 assert result.stdout.strip() == "✓ You are no longer following #foo" - result = run(cli.tags) + result = run(cli.tags, "followed") assert result.exit_code == 0 assert result.stdout.strip() == f"* #bar\t{base_url}/tags/bar" @@ -38,13 +38,13 @@ def test_tags(run, base_url): assert result.exit_code == 0 assert result.stdout.strip() == "✓ You are no longer following #bar" - result = run(cli.tags) + result = run(cli.tags, "followed") assert result.exit_code == 0 assert result.stdout.strip() == "You're not following any hashtags." def test_tags_json(run_json): - result = run_json(cli.tags, "--json") + result = run_json(cli.tags, "followed", "--json") assert result == [] result = run_json(cli.tags, "follow", "foo", "--json") @@ -52,7 +52,7 @@ def test_tags_json(run_json): assert tag.name == "foo" assert tag.following is True - result = run_json(cli.tags, "--json") + result = run_json(cli.tags, "followed", "--json") [tag] = from_dict_list(Tag, result) assert tag.name == "foo" assert tag.following is True @@ -62,7 +62,7 @@ def test_tags_json(run_json): assert tag.name == "bar" assert tag.following is True - result = run_json(cli.tags, "--json") + result = run_json(cli.tags, "followed", "--json") tags = from_dict_list(Tag, result) [bar, foo] = sorted(tags, key=lambda t: t.name) assert foo.name == "foo" @@ -80,5 +80,5 @@ def test_tags_json(run_json): assert tag.name == "bar" assert tag.following is False - result = run_json(cli.tags, "--json") + result = run_json(cli.tags, "followed", "--json") assert result == [] diff --git a/toot/cli/tags.py b/toot/cli/tags.py index 40c0800..852c0f7 100644 --- a/toot/cli/tags.py +++ b/toot/cli/tags.py @@ -6,19 +6,21 @@ from toot.cli.base import cli, pass_context, json_option, Context from toot.output import print_tag_list, print_warning -@cli.group(invoke_without_command=True) -@json_option -@click.pass_context -def tags(ctx: click.Context, json): - """List, follow, and unfollow tags +@cli.group() +def tags(): + """List, follow, and unfollow tags""" - When invoked without a command, lists followed tags.""" - if ctx.invoked_subcommand is None: - tags = api.followed_tags(ctx.obj.app, ctx.obj.user) - if json: - click.echo(pyjson.dumps(tags)) - else: - print_tag_list(tags) + +@tags.command() +@json_option +@pass_context +def followed(ctx: Context, json: bool): + """List followed tags""" + tags = api.followed_tags(ctx.app, ctx.user) + if json: + click.echo(pyjson.dumps(tags)) + else: + print_tag_list(tags) @tags.command() @@ -55,7 +57,7 @@ def unfollow(ctx: Context, tag: str, json: bool): @pass_context def tags_followed(ctx: Context): """List hashtags you follow""" - print_warning("`toot tags_followed` is deprecated in favour of `toot tags`") + print_warning("`toot tags_followed` is deprecated in favour of `toot tags followed`") response = api.followed_tags(ctx.app, ctx.user) print_tag_list(response)