Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: remove dependencies #28

Merged
merged 7 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Atlas.Provider.Core/Atlas.Provider.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@
<IsPackable>false</IsPackable>
<CheckEolTargetFramework>False</CheckEolTargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.22272.1" />
</ItemGroup>
</Project>
74 changes: 74 additions & 0 deletions src/Atlas.Provider.Core/Options.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;

namespace Atlas.Provider.Core
{
public class Options
{
public string Assembly { get; set; } = string.Empty;
public string Project { get; set; } = string.Empty;
public string StartupAssembly { get; set; } = string.Empty;
public string StartupProject { get; set; } = string.Empty;
public string ProjectDir { get; set; } = string.Empty;
public string RootNamespace { get; set; } = string.Empty;
public string Language { get; set; } = string.Empty;
public string Framework { get; set; } = string.Empty;
public string WorkingDir { get; set; } = string.Empty;
public bool Nullable { get; set; } = true;
public List<string>? PositionalArgs { get; set; }

public Options(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
switch (args[i])
{
case "--assembly":
if (i + 1 < args.Length) Assembly = args[++i];
break;
case "--project":
if (i + 1 < args.Length) Project = args[++i];
break;
case "--startup-assembly":
if (i + 1 < args.Length) StartupAssembly = args[++i];
break;
case "--startup-project":
if (i + 1 < args.Length) StartupProject = args[++i];
break;
case "--project-dir":
if (i + 1 < args.Length) ProjectDir = args[++i];
break;
case "--root-namespace":
if (i + 1 < args.Length) RootNamespace = args[++i];
break;
case "--language":
if (i + 1 < args.Length) Language = args[++i];
break;
case "--framework":
if (i + 1 < args.Length) Framework = args[++i];
break;
case "--working-dir":
if (i + 1 < args.Length) WorkingDir = args[++i];
break;
default:
if (PositionalArgs == null)
{
PositionalArgs = new List<string>();
}
PositionalArgs.Add(args[i]);
break;
}
}

if (string.IsNullOrEmpty(Assembly)) throw new ArgumentException("--assembly option requires a value.");
if (string.IsNullOrEmpty(Project)) throw new ArgumentException("--project option requires a value.");
if (string.IsNullOrEmpty(StartupAssembly)) throw new ArgumentException("--startupAssembly option requires a value.");
if (string.IsNullOrEmpty(StartupProject)) throw new ArgumentException("--startupProject option requires a value.");
if (string.IsNullOrEmpty(ProjectDir)) throw new ArgumentException("--projectDir option requires a value.");
if (string.IsNullOrEmpty(RootNamespace)) throw new ArgumentException("--rootNamespace option requires a value.");
if (string.IsNullOrEmpty(Language)) throw new ArgumentException("--language option requires a value.");
if (string.IsNullOrEmpty(Framework)) throw new ArgumentException("--framework option requires a value.");
if (string.IsNullOrEmpty(WorkingDir)) throw new ArgumentException("--workingDir option requires a value.");
}
}
}
29 changes: 9 additions & 20 deletions src/Atlas.Provider.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,23 @@ namespace Atlas.Provider.Core
{
static class Program
{
static int Main(
string assembly,
string project,
string startupAssembly,
string startupProject,
string projectDir,
string rootNamespace,
string language,
string framework,
string workingDir,
bool nullable = true,
string[]? args = null
)
static int Main(string[] args)
{
try
{
var options = new Options(args);
// prevent any output from being written to the console, including warn, info, error etc messages from EF Core
var originalOut = Console.Out;
Console.SetOut(TextWriter.Null);
using var executor = new EFDesign(
assembly,
startupAssembly,
projectDir,
options.Assembly,
options.StartupAssembly,
options.ProjectDir,
null,
rootNamespace,
language,
nullable,
args
options.RootNamespace,
options.Language,
options.Nullable,
options.PositionalArgs?.ToArray()
);
var types = executor.GetContextTypes();
foreach (var type in types)
Expand Down
Loading