First commit

This commit is contained in:
2026-04-08 20:11:20 +02:00
parent 10fe469c10
commit 79f15536a1
861 changed files with 135610 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
"""Main CLI"""
import argparse
from pathlib import Path
CPP_MAIN = """#include <iostream>
#include "functions.h"
using namespace std;
int main() {
return 0;
}
"""
CPP_FUNCTIONS = """#include "functions.h"
"""
def build_cpp_workspace(name: str) -> None:
"""Create a basic C++ workspace with main.cpp, functions.cpp, and functions.h."""
exercise_path = Path(name.replace(" ", "_")).resolve()
exercise_path.mkdir(exist_ok=True)
files = {
"main.cpp": CPP_MAIN,
"functions.cpp": CPP_FUNCTIONS,
"functions.h": "",
}
for filename, content in files.items():
file_path = exercise_path / filename
if not file_path.exists():
file_path.write_text(content, encoding="utf-8")
def parse_args() -> argparse.Namespace:
"""Parse CLI arguments."""
parser = argparse.ArgumentParser(description="Build language-specific exercise workspace.")
parser.add_argument("-n", "--name", required=True, help="Exercise name")
parser.add_argument("-l", "--language", default="cpp", help="Exercise language")
return parser.parse_args()
def main() -> None:
args = parse_args()
builders = {
"cpp": build_cpp_workspace,
# add other languages later
}
builder = builders.get(args.language)
if builder:
builder(args.name)
else:
raise ValueError(f"Unsupported language: {args.language}")
if __name__ == "__main__":
main()

View File

View File

@@ -0,0 +1,57 @@
"""
Main module for exercise creation
"""
VERSION = "1.0.0"
class CPP:
def __init__(
self,
exercise_name: str = "",
user_initialized : bool = False
) -> None:
self.exercise_name = exercise_name
if user_initialized:
self.setup_wizard()
def setup_wizard(self):
print_choices(
"Exercise name", ""
)
def print_choices(*choices: str) -> None:
for i, choice in enumerate(choices):
print(f"({i}) : {choice}")
def choose_language():
"""Function for choosing exercise language"""
print_choices("C", "C++", "Python")
user_input: str = input()
language = None
match user_input:
case "1":
language = CPP(user_initialized=True)
def choose_main():
...
def main():
"""Main function for user inputs"""
print(
f"Exercise creation tool v{VERSION}" \
"(1) : Create new exercise"
)
user_input = input()
match user_input:
case "1":
choose_language()
if __name__ == "__main__":
main()