Skip to content

Commit 403a5fc

Browse files
rename silent to no-view (#117)
1 parent 2e6156c commit 403a5fc

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ To use a different port, use `--port` option.
8484
$ pyscript run <path_of_folder> --port 9000
8585
```
8686

87-
To avoid opening a browser window, use `--silent` option.
87+
To avoid opening a browser window, use `--no-view` option.
8888

8989
```shell
90-
$ pyscript run <path_of_folder> --silent
90+
$ pyscript run <path_of_folder> --no-view
9191
```
9292

9393
### create

src/pyscript/plugins/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def run(
101101
path: Path = typer.Argument(
102102
Path("."), help="The path of the project that will run."
103103
),
104-
silent: bool = typer.Option(False, help="Open the app in web browser."),
104+
view: bool = typer.Option(True, help="Open the app in web browser."),
105105
port: int = typer.Option(8000, help="The port that the app will run on."),
106106
):
107107
"""
@@ -113,7 +113,7 @@ def run(
113113
raise cli.Abort(f"Error: Path {str(path)} does not exist.", style="red")
114114

115115
try:
116-
start_server(path, not silent, port)
116+
start_server(path, view, port)
117117
except OSError as e:
118118
if e.errno == 48:
119119
console.print(

tests/test_run_cli_cmd.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,40 @@ def test_run_server_with_default_values(
5252
assert result.exit_code == 0
5353
# EXPECT start_server_mock function to be called with the default values:
5454
# Path("."): path to local folder
55-
# show=True: the opposite of the --silent option (which default to False)
55+
# show=True: same as passing the --view option (which defaults to True)
5656
# port=8000: that is the default port
5757
start_server_mock.assert_called_once_with(Path("."), True, 8000)
5858

5959

6060
@mock.patch("pyscript.plugins.run.start_server")
61-
def test_run_server_with_silent_flag(
61+
def test_run_server_with_no_view_flag(
6262
start_server_mock, invoke_cli: CLIInvoker # noqa: F811
6363
):
6464
"""
6565
Test that when run is called without arguments the command runs with the
6666
default values
6767
"""
6868
# GIVEN a call to run without arguments
69-
result = invoke_cli("run", "--silent")
69+
result = invoke_cli("run", "--no-view")
7070
# EXPECT the command to succeed
7171
assert result.exit_code == 0
7272
# EXPECT start_server_mock function to be called with the default values:
7373
# Path("."): path to local folder
74-
# show=False: the opposite of the --silent option
74+
# show=False: same as passing the --no-view option
7575
# port=8000: that is the default port
7676
start_server_mock.assert_called_once_with(Path("."), False, 8000)
7777

7878

7979
@pytest.mark.parametrize(
8080
"run_args, expected_values",
8181
[
82-
(("--silent",), (Path("."), False, 8000)),
82+
(("--no-view",), (Path("."), False, 8000)),
8383
((BASEPATH,), (Path(BASEPATH), True, 8000)),
8484
(("--port=8001",), (Path("."), True, 8001)),
85-
(("--silent", "--port=8001"), (Path("."), False, 8001)),
86-
((BASEPATH, "--silent"), (Path(BASEPATH), False, 8000)),
85+
(("--no-view", "--port=8001"), (Path("."), False, 8001)),
86+
((BASEPATH, "--no-view"), (Path(BASEPATH), False, 8000)),
8787
((BASEPATH, "--port=8001"), (Path(BASEPATH), True, 8001)),
88-
((BASEPATH, "--silent", "--port=8001"), (Path(BASEPATH), False, 8001)),
88+
((BASEPATH, "--no-view", "--port=8001"), (Path(BASEPATH), False, 8001)),
8989
((BASEPATH, "--port=8001"), (Path(BASEPATH), True, 8001)),
9090
],
9191
)

0 commit comments

Comments
 (0)