From c1267fc5f07b2a784fd643b5a23e186f34d6a704 Mon Sep 17 00:00:00 2001 From: OverflowCat Date: Fri, 11 Aug 2023 00:25:33 +0800 Subject: [PATCH] fix: bad `get` flags --- biliarchiver/cli_tools/biliarchiver.py | 14 +++++++++++--- biliarchiver/cli_tools/get_command.py | 23 ++++++++++++++++------- pyproject.toml | 4 ---- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/biliarchiver/cli_tools/biliarchiver.py b/biliarchiver/cli_tools/biliarchiver.py index 1dd26c0..ced182c 100644 --- a/biliarchiver/cli_tools/biliarchiver.py +++ b/biliarchiver/cli_tools/biliarchiver.py @@ -2,12 +2,20 @@ import click from biliarchiver.cli_tools.up_command import up from biliarchiver.cli_tools.down_command import down from biliarchiver.cli_tools.get_command import get +from biliarchiver.version import BILI_ARCHIVER_VERSION class HelpCommand(click.Group): def format_help(self, ctx, formatter): + version_info = click.style( + f"[ biliarchiver {BILI_ARCHIVER_VERSION} ]", + fg="black", + bg="white", + bold=True, + blink=True, + ) click.echo( - """ + f""" <_-^-_> <%&&&&&&&&&&&&&&&&&&&&%*> <&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&> > __ __ __ __ < @@ -21,7 +29,7 @@ class HelpCommand(click.Group): (<&&&>/* <&&&>, <&&&> .//<&&&)> > / /_/ / / / / /__ / / / / / / | |/ / / __/ / / < <&&&>((/((<&&&>((((((((<&&&>(((/((<&&&> > \__,_/ /_/ \___/ /_/ /_/ /_/ |___/ \___/ /_/ < <&&&> ,,(<&&&> <&&&>(,, <&&&> - <&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&> + <&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&> {version_info} <&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&><""".replace( "<", "\u001b[0m" ).replace( @@ -32,7 +40,7 @@ class HelpCommand(click.Group): @click.group(cls=HelpCommand) -def biliarchiver(): +def biliarchiver(version): pass diff --git a/biliarchiver/cli_tools/get_command.py b/biliarchiver/cli_tools/get_command.py index 868859e..fb0ddb3 100644 --- a/biliarchiver/cli_tools/get_command.py +++ b/biliarchiver/cli_tools/get_command.py @@ -65,7 +65,7 @@ from rich import print """ -async def by_sapce_fav_season(url_or_sid: str) -> Path: +async def by_series(url_or_sid: str) -> Path: sid = sid = ( re.search(r"sid=(\d+)", url_or_sid).groups()[0] if url_or_sid.startswith("http") @@ -281,9 +281,9 @@ async def main( time.sleep(3) by_popular_series_one(number) else: - by_popular_series_one(popular_series) + by_popular_series_one(popular_series_number) if series: - await by_sapce_fav_season(series) + await by_series(series) if favlist: await by_favlist(favlist) @@ -305,10 +305,16 @@ class URLorIntParamType(click.ParamType): self.fail(f"{value!r} is not a valid {self.name}", param, ctx) -@click.command(help=click.style("批量获取 BV 号", fg="cyan")) +@click.command( + short_help=click.style("批量获取 BV 号", fg="cyan"), + help="请通过 flag 指定至少一种批量获取 BV 号的方式。多个不同组的 flag 同时使用时,将会先后通过不同方式获取。", +) @optgroup.group("合集") @optgroup.option( - "--series", help=click.style("合集或视频列表内视频", fg="red"), type=URLorIntParamType("sid") + "--series", + "-s", + help=click.style("合集或视频列表内视频", fg="red"), + type=URLorIntParamType("sid"), ) @optgroup.group("排行榜") @optgroup.option( @@ -357,7 +363,10 @@ class URLorIntParamType(click.ParamType): ) @optgroup.group("收藏夹") @optgroup.option( - "--favlist", help=click.style("收藏夹", fg="green"), type=URLorIntParamType("fid") + "--favlist", + "--fav", + help=click.style("收藏夹", fg="green"), + type=URLorIntParamType("fid"), ) def get(**kwargs): if ( @@ -368,7 +377,7 @@ def get(**kwargs): and not kwargs["popular_precious"] and not kwargs["popular_series"] ): - click.echo(click.style("ERROR: 请指定获取方式。", fg="red")) + click.echo(click.style("ERROR: 请指定至少一种获取方式。", fg="red")) click.echo(get.get_help(click.Context(get))) return asyncio.run(main(**kwargs)) diff --git a/pyproject.toml b/pyproject.toml index 12ae8c9..674d27b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,10 +18,6 @@ click-option-group = "^0.5.6" [tool.poetry.scripts] biliarchiver = "biliarchiver.cli_tools.biliarchiver:biliarchiver" -[tool.ruff] -ignore = ['E501'] -select = ["E", "F"] - [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"