Skip to content

Commit

Permalink
use annotation for typer options for autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Aug 5, 2024
1 parent 945f975 commit b3755a2
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions avnie/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import avro
import pyclip
import typer
from typing_extensions import Annotated

# Setup the Typer app.
app = typer.Typer(
Expand Down Expand Up @@ -57,18 +58,22 @@ def _cli_action(
@app.command()
def parse(
text: str = typer.Argument(None, help="The text to be converted."),
bijoy: bool = typer.Option(
False, "--bijoy", "-b", help="Convert the text to Bijoy layout."
),
ignore_remap: bool = typer.Option(
False, "--ignore-remap", "-i", help="Skip remapping the words."
),
from_clipboard: bool = typer.Option(
False, "--from-clipboard", "-f", help="Get the text from the clipboard."
),
copy_on_success: bool = typer.Option(
False, "--copy-on-success", "-c", help="Copy the output to the clipboard."
),
bijoy: Annotated[
bool, typer.Option("--bijoy", "-b", help="Convert the text to Bijoy layout.")
] = False,
ignore_remap: Annotated[
bool, typer.Option("--ignore-remap", "-i", help="Skip remapping the words.")
] = False,
from_clipboard: Annotated[
bool,
typer.Option("--from-clipboard", "-f", help="Get the text from the clipboard."),
] = False,
copy_on_success: Annotated[
bool,
typer.Option(
"--copy-on-success", "-c", help="Copy the output to the clipboard."
),
] = False,
) -> None:
_cli_action(
text,
Expand All @@ -83,15 +88,19 @@ def parse(
@app.command()
def reverse(
text: str = typer.Argument(None, help="The text to be converted."),
ignore_remap: bool = typer.Option(
False, "--ignore-remap", "-i", help="Skip remapping the words."
),
from_clipboard: bool = typer.Option(
False, "--from-clipboard", "-f", help="Get the text from the clipboard."
),
copy_on_success: bool = typer.Option(
False, "--copy-on-success", "-c", help="Copy the output to the clipboard."
),
ignore_remap: Annotated[
bool, typer.Option("--ignore-remap", "-i", help="Skip remapping the words.")
] = False,
from_clipboard: Annotated[
bool,
typer.Option("--from-clipboard", "-f", help="Get the text from the clipboard."),
] = False,
copy_on_success: Annotated[
bool,
typer.Option(
"--copy-on-success", "-c", help="Copy the output to the clipboard."
),
] = False,
) -> None:
_cli_action(
text,
Expand Down

0 comments on commit b3755a2

Please sign in to comment.