From ab616147fd5b5063718c03efdf885818f2a976ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20M=2E=20Thi=C3=A9ry?= Date: Thu, 29 Feb 2024 19:45:00 +0100 Subject: [PATCH] Implement travo quickstart --- travo/console_scripts.py | 44 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/travo/console_scripts.py b/travo/console_scripts.py index 69ec71b..07de82e 100755 --- a/travo/console_scripts.py +++ b/travo/console_scripts.py @@ -6,8 +6,8 @@ Implementation of the console scripts for travo """ import os -from typing import Any, Optional -from travo import Assignment +from typing import Any, Optional, Literal +from travo import Assignment, GitLab from travo.script import CLI from travo.utils import git_get_origin from travo import Homework @@ -222,6 +222,46 @@ class Travo: return JupyterCourse.validate(*files) + @staticmethod + def quickstart( + dir: str, + template: Optional[Literal["SimpleJupyterCourse"]] = "SimpleJupyterCourse", + ) -> None: + """ + Help quick start a new course + + Examples: + + travo quickstart MyCourse template=SimpleJupyterCourse + """ + forge = GitLab("https://gitlab.com") + computerlab_dir = os.path.join(dir, "ComputerLab") + course = os.path.join(computerlab_dir, "course.py") + forge.git( + [ + "clone", + "https://gitlab.com/travo-cr/demo-simple-jupyter-course/Instructors", + dir, + ], + anonymous=True, + ) + forge.git( + [ + "clone", + "https://gitlab.com/travo-cr/demo-simple-jupyter-course/ComputerLab", + computerlab_dir, + ], + anonymous=True, + ) + forge.log.info( + f"Initialized `{dir}` for holding the sources of your course material" + ) + forge.log.info( + f"and `{computerlab_dir}` to make the course available for your students." + ) + forge.log.info(f"Now edit {course} to configure your course,") + forge.log.info("and run `ComputerLab/course.py deploy`.") + def test_travo(standalone_assignment: Assignment, tmp_path: str) -> None: url = standalone_assignment.repo().http_url_to_repo -- GitLab