Skip to content

Commit

Permalink
loader: keep dependency for Loader
Browse files Browse the repository at this point in the history
  • Loading branch information
luantranminh committed Aug 8, 2024
1 parent 3c64e0a commit 669a74d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 73 deletions.
1 change: 1 addition & 0 deletions src/Atlas.Provider.Loader/Atlas.Provider.Loader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<ProjectReference Include="..\Atlas.Provider.Core\Atlas.Provider.Core.csproj" ReferenceOutputAssembly="true" />
<PackageReference Include="MinVer" Version="5.0.0" PrivateAssets="all" />
<EmbeddedResource Include="Resources\AtlasEF.targets" />
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.22272.1" />
</ItemGroup>
</Project>
93 changes: 20 additions & 73 deletions src/Atlas.Provider.Loader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,78 +6,25 @@ static class Program
{
private const string AssemblyName = "Atlas.Provider.Core";

static int Main(string[] args)
/// <summary>
/// This class used to load the current context into Core Commands
/// </summary>
/// <param name="project">Relative path to the project folder of the target project. Default value is the current folder.</param>
/// <param name="startupProject">Relative path to the project folder of the startup project. Default value is the current folder.</param>
/// <param name="framework">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.</param>
/// <param name="context">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.</param>
/// <param name="noBuild">Don't build the project. Intended to be used when the build is up-to-date.</param>
/// <param name="args"></param>
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<string>();
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);
Expand Down Expand Up @@ -124,9 +71,9 @@ static int Main(string[] args)
}

var arguments = new List<string>();
if (extraArgs != null)
if (args != null)
{
arguments.AddRange(extraArgs);
arguments.AddRange(args);
}
arguments.AddRange([
"--root-namespace", _project.RootNamespace!,
Expand Down

0 comments on commit 669a74d

Please sign in to comment.