Skip to content
Myr

✨ Support __main__.py, passing prog_name to callable (#120)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Teymour Aldridge · committed by GitHub · parent f6304f1 · Browse files · 3 files+27 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>

Diff stats

3 files+27 added−2 removed

  • tests:+25 added−0 removed
  • other:+2 added−2 removed

3 files+27 added−2 removed

added:tests/assets/prog_name.py+12 added
1import typer23app = typer.Typer()456@app.command()7def main(i: int): # pragma: no cover8 pass91011if __name__ == "__main__":12 app(prog_name="custom-name")
added:tests/test_prog_name.py+13 added
1import subprocess2from pathlib import Path345def test_custom_prog_name():6 file_path = Path(__file__).parent / "assets/prog_name.py"7 result = subprocess.run(8 ["coverage", "run", str(file_path), "--help"],9 stdout=subprocess.PIPE,10 stderr=subprocess.PIPE,11 encoding="utf-8",12 )13 assert "Usage: custom-name [OPTIONS] I" in result.stdout
modified:typer/main.py+2 added-2 removed
207 unmodified lines
208 deprecated=deprecated,209 )210 )211212 def __call__(self) -> Any:213 return get_command(self)()212 def __call__(self, *args: Any, **kwargs: Any) -> Any:213 return get_command(self)(*args, **kwargs)214215216def get_group(typer_instance: Typer) -> click.Command:217 group = get_group_from_info(TyperInfo(typer_instance))
631 unmodified lines