Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit e5f722b

Browse files
committed
refactor(main): use Annotated
1 parent 49beeb3 commit e5f722b

1 file changed

Lines changed: 42 additions & 32 deletions

File tree

pacup/__main__.py

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from os import get_terminal_size, makedirs
3838
from pathlib import Path
3939
from shutil import rmtree
40-
from typing import NoReturn, Optional
40+
from typing import Annotated, NoReturn, Optional
4141

4242
import typer
4343
from httpx import AsyncClient, HTTPStatusError, RequestError, Response
@@ -67,8 +67,7 @@
6767
__version__ = "1.1.0 Io"
6868

6969
app = typer.Typer(
70-
name="pacup",
71-
context_settings={"help_option_names": ["-h", "--help"]}
70+
name="pacup", context_settings={"help_option_names": ["-h", "--help"]}
7271
)
7372

7473

@@ -273,35 +272,46 @@ def version_callback(value: bool) -> None:
273272
# HACK: This uses `Optional` due to a typer bug: https://github.com/tiangolo/typer/issues/533
274273
@app.command()
275274
def command(
276-
show_repology: Optional[bool] = typer.Option(
277-
None,
278-
"-r",
279-
"--show-repology",
280-
help="Show the parsed repology data and exit.",
281-
),
282-
debug: Optional[bool] = typer.Option(
283-
None, "-d", "--debug", help="Turn on debugging mode."
284-
),
285-
_: Optional[bool] = typer.Option(
286-
None,
287-
"-v",
288-
"--version",
289-
help="Show the version and exit.",
290-
callback=version_callback,
291-
is_eager=True,
292-
),
293-
ship: Optional[bool] = typer.Option(
294-
None, "-s", "--ship", help="Prepare the pacscript for shipping to upstream."
295-
),
296-
pacscripts: list[Path] = typer.Argument(
297-
...,
298-
help="The pacscripts to update.",
299-
exists=True,
300-
writable=True,
301-
dir_okay=False,
302-
callback=validate_parameters,
303-
autocompletion=autocomplete_command,
304-
),
275+
pacscripts: Annotated[
276+
list[Path],
277+
typer.Argument(
278+
show_default=False,
279+
exists=True,
280+
writable=True,
281+
dir_okay=False,
282+
callback=validate_parameters,
283+
autocompletion=autocomplete_command,
284+
help="The pacscripts to update.",
285+
),
286+
],
287+
show_repology: Annotated[
288+
Optional[bool],
289+
typer.Option(
290+
"-r",
291+
"--show-repology",
292+
help="Show the parsed repology data and exit.",
293+
),
294+
] = None,
295+
debug: Annotated[
296+
Optional[bool],
297+
typer.Option("-d", "--debug", help="Turn on debugging mode."),
298+
] = None,
299+
_: Annotated[
300+
Optional[bool],
301+
typer.Option(
302+
"-v",
303+
"--version",
304+
help="Show the version and exit.",
305+
callback=version_callback,
306+
is_eager=True,
307+
),
308+
] = None,
309+
ship: Annotated[
310+
Optional[bool],
311+
typer.Option(
312+
"-s", "--ship", help="Prepare the pacscript for shipping to upstream."
313+
),
314+
] = None,
305315
) -> NoReturn:
306316
"""
307317
Updates specified pacscripts.

0 commit comments

Comments
 (0)