Skip to content

Commit 4dcfb90

Browse files
authored
Merge pull request #490 from MetOffice/launch-tutorial
add sub commands to make tutorial easier to use
2 parents bb18fb0 + a3a37bb commit 4dcfb90

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

doc/source/start.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,24 @@ to hands on experience.
4242
4343
~: forest tutorial --help
4444
45-
The only argument `forest-tutorial` needs is a directory to place
46-
files. Go ahead and run the tutorial command to
45+
The only argument `forest tutorial files` needs is a directory to place
46+
files into. Go ahead and run the tutorial command to
4747
get your hands on some files that `forest` can analyse.
4848

4949
.. code-block:: bash
5050
51-
~: forest tutorial .
51+
~: forest tutorial files .
5252
5353
The above snippet can be used to populate the current working directory with
54-
all of the inputs needed to run the `forest` command line interface
54+
all of the inputs needed to run the `forest` command line interface.
55+
56+
If you get stuck and want a quick way to open the tutorial page.
57+
58+
.. code-block:: bash
59+
60+
~: forest tutorial launch
61+
62+
The launch command opens a browser tab at the official tutorial guide.
5563

5664
Example - Unified model output
5765
------------------------------

forest/cli/alternative.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414

1515
app = typer.Typer(help="Command line interface for FOREST web application")
1616

17+
# Tutorial sub-command
18+
tutorial_app = typer.Typer(help="Guide to getting started")
19+
app.add_typer(tutorial_app, name="tutorial")
20+
tutorial_app.command(name="files")(forest.tutorial.main.main)
21+
22+
23+
@tutorial_app.command()
24+
def launch():
25+
"""Open documentation pages"""
26+
typer.secho("Opening tutorial page...\n", fg=typer.colors.CYAN)
27+
typer.launch(
28+
"https://forest-informaticslab.readthedocs.io/en/latest/start.html#tutorial"
29+
)
30+
31+
1732
# Driver sub-command
1833
driver_app = typer.Typer(help="Describe available drivers")
1934
app.add_typer(driver_app, name="driver")
@@ -134,9 +149,6 @@ def ctl(
134149
return subprocess.call(command)
135150

136151

137-
app.command(name="tutorial")(forest.tutorial.main.main)
138-
139-
140152
app.command(name="db")(forest.db.main.main)
141153

142154

test/test_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_main_calls_build_all_with_build_dir(build_dir, file_names):
3434
if isinstance(file_names, str):
3535
file_names = [file_names]
3636

37-
runner.invoke(app, ["tutorial", build_dir])
37+
runner.invoke(app, ["tutorial", "files", build_dir])
3838

3939
for file_name in file_names:
4040
assert os.path.exists(os.path.join(build_dir, file_name)), file_name

0 commit comments

Comments
 (0)