using System.CommandLine; using MycroForge.CLI.Extensions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using MycroForge.CLI.CodeGen; // using var host = Host // .CreateDefaultBuilder() // .ConfigureServices((_, services) => // { // services // .AddServices() // .AddCommands(); // }) // .Build(); // // try // { // await host.Services.GetRequiredService() // .InvokeAsync(args.Length == 0 ? ["--help"] : args); // } // catch(Exception e) // { // Console.WriteLine(e.Message); // } // var rewrite = new EntityFieldReader(string.Join("\n", [ // "from typing import Any, Dict", // "from sqlalchemy import JSON, DateTime, String, func", // "from sqlalchemy.orm import Mapped, mapped_column", // "from sqlalchemy.dialects.mssql import TEXT", // "from orm.entities.entity_base import EntityBase", // "class Product(EntityBase):", // "\t__tablename__ = \"products\"", // "\tid: Mapped[int] = mapped_column(primary_key=True)", // "\tmain_key: Mapped[str] = mapped_column(String(255), unique=True, nullable=False)", // "\terp_key: Mapped[str] = mapped_column(String(255), unique=True, nullable=True)", // "\tpim_key: Mapped[str] = mapped_column(String(255), unique=True, nullable=True)", // "\twms_key: Mapped[str] = mapped_column(String(255), unique=True, nullable=True)", // "\tshared_key: Mapped[str] = mapped_column(String(255), nullable=True)", // "\taxis_1_code: Mapped[str] = mapped_column(String(255), nullable=True)", // "\taxis_1_value: Mapped[str] = mapped_column(String(255), nullable=True)", // "\taxis_2_code: Mapped[str] = mapped_column(String(255), nullable=True)", // "\taxis_2_value: Mapped[str] = mapped_column(String(255), nullable=True)", // "\taxis_3_code: Mapped[str] = mapped_column(String(255), nullable=True)", // "\taxis_3_value: Mapped[str] = mapped_column(String(255), nullable=True)", // "\tdata: Mapped[Dict[str, Any]] = mapped_column(JSON(), nullable=True)", // "\tdata_string: Mapped[str] = mapped_column(TEXT(), nullable=True)", // "\tcreated_at: Mapped[DateTime] = mapped_column(DateTime(timezone=True), default=func.now())", // "\tupdated_at: Mapped[DateTime] = mapped_column(DateTime(timezone=True), default=func.now(), onupdate=func.now())", // "def __repr__(self) -> str:", // "\treturn f\"Product(id={self.id!r}, main_key={self.main_key!r}, shared_key={self.shared_key})\"" // ])).ReadFields(); // // rewrite.ForEach(f => // { // Console.WriteLine($"name={f.Name}, type={f.Type}"); // }); var main = new MainModifier(string.Join("\n", await File.ReadAllLinesAsync("scripts/user.py"))); main.Initialize(); Console.WriteLine(main.Rewrite());