6
6
import logging
7
7
import os
8
8
import platform
9
+ import shutil
9
10
from pathlib import Path
10
11
11
12
import typer
20
21
21
22
22
23
@app .command ()
23
- def main () -> None :
24
+ def main (
25
+ output : Path = typer .Option (
26
+ Path .cwd () / "dotnet-classes" , help = "Output directory for the generated C# classes. default: dotnet-classes"
27
+ )
28
+ ) -> None :
24
29
"""
25
30
It will use BO4E-Schema-Tool and
26
31
generate C# classes from the BO4E schema files with help of Quicktype.
32
+
33
+ args:
34
+ output (Path): Output directory for the generated C# classes.
27
35
"""
28
36
# Define the base directories
29
37
project_root = Path .cwd () # Root directory of the project
30
38
schemas_dir = project_root / "schemas"
31
- output_dir = project_root / "dotnet-classes"
39
+ generated_output_dir = project_root / "generated- dotnet-classes"
32
40
33
41
# Determine the Quicktype executable path based on the operating system
34
42
path_app_data = os .getenv ("APPDATA" )
@@ -40,11 +48,16 @@ def main() -> None:
40
48
# Install BO4E-Schema-Tool and generate schemas
41
49
running_bo4e_schema_tool (str (schemas_dir ))
42
50
43
- # Generate C# classes
44
- generate_csharp_classes (Path (project_root ), Path (schemas_dir ), Path (output_dir ), quicktype_executable )
51
+ # Generate C# classes from the schemas
52
+ generate_csharp_classes (project_root , schemas_dir , generated_output_dir , quicktype_executable )
53
+
54
+ # Copy the generated files and subdirectories to the output directory
55
+ if output .exists ():
56
+ shutil .rmtree (output ) # Remove existing output directory if it exists
57
+ shutil .copytree (generated_output_dir , output ) # Copy the generated output to the final output directory
45
58
46
59
# Remove duplicate class and enum definitions
47
- process_directory (Path ( output_dir ) )
60
+ process_directory (output )
48
61
49
62
50
63
def cli () -> None :
0 commit comments