1
1
"""The main CLI entrypoint and commands."""
2
+ import webbrowser
2
3
from pathlib import Path
3
4
from typing import Optional
4
5
@@ -40,9 +41,20 @@ def version() -> None:
40
41
41
42
@app .command ()
42
43
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." ),
46
58
) -> None :
47
59
"""Wrap a Python script inside an HTML file."""
48
60
if input_file is not None :
@@ -53,3 +65,7 @@ def wrap(
53
65
if command :
54
66
assert output is not None
55
67
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