From 669a74d95878df9a2313f1b940fff22458fc0d31 Mon Sep 17 00:00:00 2001 From: luantranminh Date: Thu, 8 Aug 2024 14:00:35 +0700 Subject: [PATCH] loader: keep dependency for Loader --- .../Atlas.Provider.Loader.csproj | 1 + src/Atlas.Provider.Loader/Program.cs | 93 ++++--------------- 2 files changed, 21 insertions(+), 73 deletions(-) diff --git a/src/Atlas.Provider.Loader/Atlas.Provider.Loader.csproj b/src/Atlas.Provider.Loader/Atlas.Provider.Loader.csproj index 0f3b836..7225d92 100644 --- a/src/Atlas.Provider.Loader/Atlas.Provider.Loader.csproj +++ b/src/Atlas.Provider.Loader/Atlas.Provider.Loader.csproj @@ -36,5 +36,6 @@ + \ No newline at end of file diff --git a/src/Atlas.Provider.Loader/Program.cs b/src/Atlas.Provider.Loader/Program.cs index d0ae0df..1876e45 100644 --- a/src/Atlas.Provider.Loader/Program.cs +++ b/src/Atlas.Provider.Loader/Program.cs @@ -6,78 +6,25 @@ static class Program { private const string AssemblyName = "Atlas.Provider.Core"; - static int Main(string[] args) + /// + /// This class used to load the current context into Core Commands + /// + /// Relative path to the project folder of the target project. Default value is the current folder. + /// Relative path to the project folder of the startup project. Default value is the current folder. + /// The Target Framework Moniker for the target framework. Use when the project file specifies multiple target frameworks, and you want to select one of them. + /// The DbContext class to use. Class name only or fully qualified with namespaces. + /// If this option is omitted, EF Core will find the context class. If there are multiple context classes, this option is required. + /// Don't build the project. Intended to be used when the build is up-to-date. + /// + static int Main( + string project, + string startupProject, + string framework, + string context, + bool noBuild = false, + string[]? args = null + ) { - string? project = null; - string? startupProject = null; - string? framework = null; - string? context = null; - bool noBuild = false; - var extraArgs = new List(); - bool parsingExtraArgs = false; - - for (int i = 0; i < args.Length; i++) - { - if (args[i] == "--") - { - parsingExtraArgs = true; - continue; - } - if (parsingExtraArgs) - { - extraArgs.Add(args[i]); - } - else - { - switch (args[i]) - { - case "--project": - if (i + 1 < args.Length) - { - project = args[++i]; - } - else - { - Console.WriteLine("Error: --project option requires a value."); - } - break; - case "--startup-project": - if (i + 1 < args.Length) - { - startupProject = args[++i]; - } - else - { - Console.WriteLine("Error: --startup-project option requires a value."); - } - break; - case "--framework": - if (i + 1 < args.Length) - { - framework = args[++i]; - } - else - { - Console.WriteLine("Error: --framework option requires a value."); - } - break; - case "--context": - if (i + 1 < args.Length) - { - context = args[++i]; - } - else - { - Console.WriteLine("Error: --context option requires a value."); - } - break; - case "--no-build": - noBuild = true; - break; - } - } - } - try { var (projectFile, startupProjectFile) = Project.ResolveProjects(project, startupProject); @@ -124,9 +71,9 @@ static int Main(string[] args) } var arguments = new List(); - if (extraArgs != null) + if (args != null) { - arguments.AddRange(extraArgs); + arguments.AddRange(args); } arguments.AddRange([ "--root-namespace", _project.RootNamespace!,