提交 58fd98bf 编写于 作者: J Jared Parsons

Moved RepoUtil config file to the common locatino

上级 1cc7221f
......@@ -12,7 +12,7 @@ internal static class Program
{
private sealed class ParsedArgs
{
internal string RepoDataPath { get; set; }
internal string RepoUtilDataPath { get; set; }
internal string SourcesPath { get; set; }
internal string[] RemainingArgs { get; set; }
}
......@@ -25,7 +25,9 @@ internal static int Main(string[] args)
try
{
if (Run(args))
{
result = 0;
}
}
catch (ConflictingPackagesException ex)
{
......@@ -55,7 +57,7 @@ private static bool Run(string[] args)
return false;
}
var repoConfig = RepoConfig.ReadFrom(parsedArgs.RepoDataPath);
var repoConfig = RepoConfig.ReadFrom(parsedArgs.RepoUtilDataPath);
var command = func(repoConfig, parsedArgs.SourcesPath);
return command.Run(Console.Out, parsedArgs.RemainingArgs);
}
......@@ -67,8 +69,6 @@ private static bool TryParseCommandLine(string[] args, out ParsedArgs parsedArgs
// Setup the default values
var binariesPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(AppContext.BaseDirectory))));
parsedArgs.SourcesPath = Path.GetDirectoryName(binariesPath);
parsedArgs.RepoDataPath = Path.Combine(AppContext.BaseDirectory, "RepoData.json");
var index = 0;
if (!TryParseCommon(args, ref index, parsedArgs))
......@@ -81,12 +81,24 @@ private static bool TryParseCommandLine(string[] args, out ParsedArgs parsedArgs
return false;
}
parsedArgs.SourcesPath = parsedArgs.SourcesPath ?? GetDirectoryName(AppContext.BaseDirectory, 5);
parsedArgs.RepoUtilDataPath = parsedArgs.RepoUtilDataPath ?? Path.Combine(parsedArgs.SourcesPath, @"build\config\RepoUtilData.json");
parsedArgs.RemainingArgs = index >= args.Length
? Array.Empty<string>()
: args.Skip(index).ToArray();
return true;
}
private static string GetDirectoryName(string path, int depth)
{
for (var i = 0; i < depth; i++)
{
path = Path.GetDirectoryName(path);
}
return path;
}
private static bool TryParseCommon(string[] args, ref int index, ParsedArgs parsedArgs)
{
while (index < args.Length)
......@@ -114,6 +126,20 @@ private static bool TryParseCommon(string[] args, ref int index, ParsedArgs pars
}
break;
}
case "-config":
{
if (index < args.Length)
{
parsedArgs.RepoUtilDataPath = args[index];
index++;
}
else
{
Console.WriteLine($"The -config switch needs a value");
return false;
}
break;
}
default:
Console.Write($"Option {arg} is unrecognized");
return false;
......
......@@ -63,9 +63,6 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="RepoData.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册