Skip to content

Commit 4b296c5

Browse files
committed
Add better help documentation and option to open output in web browser
1 parent be29028 commit 4b296c5

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/pyscript/cli.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The main CLI entrypoint and commands."""
2+
import webbrowser
23
from pathlib import Path
34
from typing import Optional
45

@@ -40,9 +41,20 @@ def version() -> None:
4041

4142
@app.command()
4243
def wrap(
43-
input_file: Optional[Path] = typer.Argument(None),
44-
command: Optional[str] = typer.Option(None, "-c", "--command"),
45-
output: Optional[Path] = typer.Option(None, "-o"),
44+
input_file: Optional[Path] = typer.Argument(
45+
None,
46+
help="An optional path to the input .py script. If not provided, must use '-c' flag.",
47+
),
48+
command: Optional[str] = typer.Option(
49+
None, "-c", "--command", help="If provided, embed a single command string."
50+
),
51+
output: Optional[Path] = typer.Option(
52+
None,
53+
"-o",
54+
"--output",
55+
help="Path to the resulting HTML output file. Defaults to input_file with suffix replaced.",
56+
),
57+
show: Optional[bool] = typer.Option(None, help="Open output file in web browser."),
4658
) -> None:
4759
"""Wrap a Python script inside an HTML file."""
4860
if input_file is not None:
@@ -53,3 +65,7 @@ def wrap(
5365
if command:
5466
assert output is not None
5567
string_to_html(command, output)
68+
69+
if show:
70+
console.print("Opening in web browser!")
71+
webbrowser.open(f"file://{output.resolve()}")

0 commit comments

Comments
 (0)