Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing prog_name #120

Merged
merged 4 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/assets/prog_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import typer

app = typer.Typer()


@app.command()
def main(i: int): # pragma: no cover
pass


if __name__ == "__main__":
app(prog_name="custom-name")
13 changes: 13 additions & 0 deletions tests/test_prog_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import subprocess
from pathlib import Path


def test_custom_prog_name():
file_path = Path(__file__).parent / "assets/prog_name.py"
result = subprocess.run(
["coverage", "run", str(file_path), "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
)
assert "Usage: custom-name [OPTIONS] I" in result.stdout
4 changes: 2 additions & 2 deletions typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def add_typer(
)
)

def __call__(self) -> Any:
return get_command(self)()
def __call__(self, *args: Any, **kwargs: Any) -> Any:
return get_command(self)(*args, **kwargs)


def get_group(typer_instance: Typer) -> click.Command:
Expand Down