Last active
February 14, 2024 14:57
-
-
Save joshuadavidthomas/f4bf90790d5d8ca11ad378f4b042d73a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import click | |
@click.command() | |
@click.argument("name", type=str, default="World") | |
def main(name: str): | |
print(f"Hello, {name.title()}!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import typer | |
from typing_extensions import Annotated | |
cli = typer.Typer() | |
@cli.command() | |
def command(name: Annotated[str, typer.Argument()] = "World") -> None: | |
print(f"Hello {name.title()}!") | |
def main(): | |
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import typer | |
from typing_extensions import Annotated | |
cli = typer.Typer() | |
@cli.command() | |
def command(name: Annotated[str, typer.Argument()] = "World") -> None: | |
print(f"Hello {name.title()}!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import typer | |
from typing_extensions import Annotated | |
def command(name: Annotated[str, typer.Argument()] = "World") -> None: | |
print(f"Hello {name.title()}!") | |
def cli(): | |
typer.run(command) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[project] | |
name = "test" | |
version = "0.1.0" | |
description = "Test of Click vs. Typer" | |
authors = [ | |
{ name = "Josh", email = "josh@joshthomas.dev" } | |
] | |
dependencies = [ | |
"typer[all]>=0.9.0", | |
"click>=8.1.7", | |
] | |
readme = "README.md" | |
requires-python = ">= 3.11" | |
[project.scripts] | |
hello-click = "test.hello_click:main" | |
hello-typer = "test.hello_typer:main" | |
hello-typer-alt1 = "test.hello_typer_alt1:cli" | |
hello-typer-alt2 = "test.hello_typer_alt2:cli" | |
[build-system] | |
requires = ["hatchling"] | |
build-backend = "hatchling.build" | |
[tool.hatch.build.targets.wheel] | |
packages = ["src/test"] |
Author
joshuadavidthomas
commented
Feb 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment