From 7163d587f9fe746b9766ec364847e39ba79c2261 Mon Sep 17 00:00:00 2001 From: Boyan Date: Thu, 21 Nov 2024 10:41:23 +0100 Subject: [PATCH] Added file path optional parameter --- README.md | 2 +- temmies_cli/cli.py | 5 +++-- temmies_cli/commands/init.py | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 147ead3..d6170fb 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ temmies init / ### Optional args - `-s` : Search for an assignment instead of providing the link i.e. `temmies init -s "Advanced Algorithms" `. - `-t `: Specify where you want your tests to be (relative to the parent of each assignment folder). Default is `.`. - +- `-f `: Specify where you want your files to be (relative to the parent of each assignment folder). Default is `.`. ### File hierarchy example Once the command is ran: ``` diff --git a/temmies_cli/cli.py b/temmies_cli/cli.py index b7c610a..85b61ec 100644 --- a/temmies_cli/cli.py +++ b/temmies_cli/cli.py @@ -15,13 +15,14 @@ def cli(): @click.argument('path', required=False, default='.') @click.option('-s', '--search', help='Search for an assignment by name.') @click.option('-t', '--test-folder', default='.', help='Specify the name of the test cases folder.') -def init(year_course_path, path, search, test_folder): +@click.option('-f', '--file-folder', default='.', help='Specify the name of the file folder.') +def init(year_course_path, path, search, test_folder, file_folder): """ Initialize a new assignment or folder. YEAR_COURSE_PATH: Format '{startyear-endyear}/{courseTag}' or '{startyear-endyear}/{courseTag}/{folder_or_assignment}'. """ - init_assignment(year_course_path, path, search, test_folder) + init_assignment(year_course_path, path, search, test_folder, file_folder) @cli.command() diff --git a/temmies_cli/commands/init.py b/temmies_cli/commands/init.py index 5f5026b..6b1c2b4 100644 --- a/temmies_cli/commands/init.py +++ b/temmies_cli/commands/init.py @@ -6,7 +6,7 @@ import tqdm -def init_assignment(year_course_assignment, path, search, test_folder): +def init_assignment(year_course_assignment, path, search, test_folder, file_folder): """ Initialize a new assignment or course. """ @@ -38,12 +38,12 @@ def init_assignment(year_course_assignment, path, search, test_folder): if is_course: root_path = os.path.join(path, course.title.lower().replace(" ", "_")) click.echo(f"Initializing entire course '{course.title}'...") - create_assignment_files(course, root_path, user, test_folder) + create_assignment_files(course, root_path, user, test_folder, file_folder) else: root_path = os.path.join( path, assignment.title.lower().replace(" ", "_")) click.echo(f"Initializing assignment '{assignment.title}'...") - create_assignment_files(assignment, root_path, user, test_folder) + create_assignment_files(assignment, root_path, user, test_folder, file_folder) click.echo(f"Initialized at '{root_path}'.")