diff --git a/typer/__init__.py b/typer/__init__.py index ab6f872..4f36c76 100644 --- a/typer/__init__.py +++ b/typer/__init__.py @@ -5,4 +5,43 @@ __version__ = "0.0.1" from .main import Typer, run # noqa from .params import Option, Argument # noqa from .models import Context, TextFile, BinaryFileRead, BinaryFileWrite # noqa -from click import echo # noqa + +# Utilities +from click.utils import ( # noqa + echo, + get_binary_stream, + get_text_stream, + open_file, + format_filename, + get_app_dir, + get_os_args, +) + +# Terminal functions +from click.termui import ( # noqa + prompt, + confirm, + get_terminal_size, + echo_via_pager, + progressbar, + clear, + style, + unstyle, + secho, + edit, + launch, + getchar, + pause, +) + +from click.exceptions import ( # noqa + ClickException, + UsageError, + BadParameter, + FileError, + Abort, + NoSuchOption, + BadOptionUsage, + BadArgumentUsage, + MissingParameter, +) diff --git a/typer/testing.py b/typer/testing.py new file mode 100644 index 0000000..3ef28f0 --- /dev/null +++ b/typer/testing.py @@ -0,0 +1,27 @@ +from click.testing import Result, CliRunner as ClickCliRunner # noqa +from typer.main import get_command as _get_command + + +class CliRunner(ClickCliRunner): + def invoke( + self, + cli, + args=None, + input=None, + env=None, + catch_exceptions=True, + color=False, + mix_stderr=False, + **extra + ) -> Result: + use_cli = _get_command(cli) + return super().invoke( + use_cli, + args=args, + input=input, + env=env, + catch_exceptions=catch_exceptions, + color=color, + mix_stderr=mix_stderr, + **extra + )