Skip to content

Commit

Permalink
Add ability to pass down arguments + test.
Browse files Browse the repository at this point in the history
  • Loading branch information
teymour-aldridge committed Jun 21, 2020
1 parent 45fb7c4 commit 79e6a8f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/test_tutorial/test_options/test_help/prog_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import typer

import subprocess

app = typer.Typer()


@app.command()
def main(i: int):
pass


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


def test_custom_prog_name():
result = subprocess.run(
["python", "prog_name.py", "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
)
assert "custom-name" in result
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

0 comments on commit 79e6a8f

Please sign in to comment.