Skip to content

Commit ba08059

Browse files
committed
Tweak hands-on-structure.md
1 parent 9567d9d commit ba08059

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

docs/architecture/hands-on-structure.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,41 @@ Hands-ons are not graded and the progress is not tracked. They are only present
1212

1313
{: .note }
1414

15-
Git-Mastery users will prefix `hp-` before the hands-on names, but internally, we do not use this prefix as the `hands_on` folder is sufficient for us.
15+
Git-Mastery uses the format `hp-<hands-on-name>` for hands-on names (e.g., `hp-init-repo`), to differentiate them from exercise names. Internally, we use a `hands_on/` folder (instead of the `hp-` prefix) to differentiate hands-on files from exercise files (e.g., `hands_on/init_repo.py`).
1616

1717
## File structure
1818

19-
Since the hands-on is only comprised of a single file, there isn't a lot of complexity to it.
19+
Since the hands-on is only comprised of a single file, there isn't a lot of complexity to it. Given below is an example:
2020

2121
```python
22-
import subprocess
23-
from sys import exit
24-
from typing import List, Optional
22+
import os
23+
24+
from exercise_utils.cli import run_command
25+
from exercise_utils.file import append_to_file, create_or_update_file
26+
from exercise_utils.git import add, init
2527

2628
__requires_git__ = True
27-
__requires_github__ = True
28-
29-
30-
def run_command(command: List[str], verbose: bool) -> Optional[str]:
31-
try:
32-
result = subprocess.run(
33-
command,
34-
capture_output=True,
35-
text=True,
36-
check=True,
37-
)
38-
if verbose:
39-
print(result.stdout)
40-
return result.stdout
41-
except subprocess.CalledProcessError as e:
42-
if verbose:
43-
print(e.stderr)
44-
exit(1)
29+
__requires_github__ = False
4530

4631

4732
def download(verbose: bool):
48-
pass
33+
os.makedirs("things")
34+
os.chdir("things")
35+
init(verbose)
36+
create_or_update_file(
37+
"fruits.txt",
38+
"""
39+
apples
40+
bananas
41+
cherries
42+
""",
43+
)
44+
add(["fruits.txt"], verbose)
45+
run_command(["git", "add", "fruits.txt"], verbose)
46+
append_to_file("fruits.txt", "dragon fruits")
47+
4948
```
5049

51-
The setup instructions of the hands-on go under `download`.
50+
The setup instructions of the hands-on go under the `download` function.
5251

5352
`__requires_git__` and `__requires_github__` tells the Git-Mastery app whether to run automatic verification that the student has already setup Git and/or Github CLI correctly!

0 commit comments

Comments
 (0)