kinda finished
This commit is contained in:
parent
2d4fa55e91
commit
71d36c680f
@ -8,15 +8,7 @@ void ProcessDirectory(string baseDir) {
|
||||
var fs = Path.Combine(baseDir, subDir);
|
||||
if (File.Exists(fs))
|
||||
{
|
||||
if (Path.GetFileName(fs) == "BUILD")
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(fs);
|
||||
Console.WriteLine("======== ======== ======== ======== ======== ======== ======== ========");
|
||||
FormatBuildFile(fs);
|
||||
Console.WriteLine("======== ======== ======== ======== ======== ======== ======== ========");
|
||||
Console.WriteLine();
|
||||
}
|
||||
if (Path.GetFileName(fs) == "BUILD") FormatBuildFile(fs);
|
||||
}
|
||||
else if (Directory.Exists(fs))
|
||||
{
|
||||
@ -30,11 +22,10 @@ void FormatBuildFile(string filename)
|
||||
var oldcontent = File.ReadAllText(filename);
|
||||
var newcontent = FormatFile(filename, oldcontent);
|
||||
|
||||
if (oldcontent != newcontent)
|
||||
{
|
||||
//File.WriteAllText(filename, newcontent);
|
||||
Console.WriteLine("Auto-Formatted file :: " + filename);
|
||||
}
|
||||
if (oldcontent == newcontent) return;
|
||||
|
||||
File.WriteAllText(filename, newcontent);
|
||||
Console.WriteLine("Auto-Formatted file :: " + filename);
|
||||
}
|
||||
|
||||
string FormatFile(string filename, string content)
|
||||
@ -52,15 +43,7 @@ string FormatFile(string filename, string content)
|
||||
|
||||
var newDeps = FormatDeps(filename, linenum, oldDeps);
|
||||
|
||||
if (oldDeps != newDeps)
|
||||
{
|
||||
Console.WriteLine("+++++++++++++ OLD +++++++++++++++++");
|
||||
Console.WriteLine(oldDeps);
|
||||
Console.WriteLine("++++++++++++++ NEW ++++++++++++++++");
|
||||
Console.WriteLine(newDeps);
|
||||
Console.WriteLine("++++++++++++++++++++++++++++++");
|
||||
Console.WriteLine();
|
||||
}
|
||||
if (oldDeps != newDeps) content = content.Replace(oldDeps, newDeps);
|
||||
}
|
||||
|
||||
return content;
|
||||
@ -90,7 +73,7 @@ string FormatDeps(string filename, int linenum, string deps)
|
||||
return result;
|
||||
}
|
||||
|
||||
(int group, string clean, string raw) GetDepGroup(string filename, int linenum, string value)
|
||||
(int group, string sgroup, string clean, string raw) GetDepGroup(string filename, int linenum, string value)
|
||||
{
|
||||
var v = value.Trim();
|
||||
|
||||
@ -101,16 +84,38 @@ string FormatDeps(string filename, int linenum, string deps)
|
||||
|
||||
if (rowA)
|
||||
{
|
||||
v = v.Substring(1, v.Length - 4);
|
||||
v = v.Substring(1, v.Length - 3);
|
||||
}
|
||||
else if (rowB)
|
||||
{
|
||||
v = v.Substring(1, v.Length - 3);
|
||||
v = v.Substring(1, v.Length - 2);
|
||||
}
|
||||
|
||||
v = v.Trim();
|
||||
|
||||
if (v.StartsWith(":")) return (100, "local", v, value);
|
||||
|
||||
if (v.StartsWith("//common")) return (200, "common", v, value);
|
||||
if (v.StartsWith("//apcommon")) return (201, "common", v, value);
|
||||
|
||||
if (v.StartsWith("//accessor")) return (220, "accessor", v, value);
|
||||
if (v.StartsWith("//models")) return (221, "models", v, value);
|
||||
if (v.StartsWith("//routing")) return (222, "routing", v, value);
|
||||
if (v.StartsWith("//service")) return (223, "service", v, value);
|
||||
if (v.StartsWith("//artifacts")) return (224, "artifacts", v, value);
|
||||
|
||||
//TODO group
|
||||
|
||||
return (0, v, value);
|
||||
if (v.StartsWith("//services")) return (251, "services", v, value);
|
||||
if (v.StartsWith("//gateways")) return (252, "gateways", v, value);
|
||||
if (v.StartsWith("//jobs")) return (253, "jobs", v, value);
|
||||
|
||||
if (v.StartsWith("//proto/common:")) return (401, "commonproto", v, value);
|
||||
if (v.StartsWith("//proto")) return (402, "proto", v, value);
|
||||
|
||||
if (v.StartsWith("//library/go/private")) return (500, "privatelib", v, value);
|
||||
|
||||
if (v.StartsWith("//library/go:")) return (501, "golib", v, value);
|
||||
|
||||
if (v.StartsWith("//library/go/")) return (502, "sublib", v, value);
|
||||
|
||||
throw new Exception($"unknown dep group in file {filename}:{linenum} => '{v}'");
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>please_build_formatter</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
16
pbf.sln
Normal file
16
pbf.sln
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pbf", "pbf.csproj", "{1B977662-654F-4FB6-AB8D-56DA3D1BB93D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1B977662-654F-4FB6-AB8D-56DA3D1BB93D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1B977662-654F-4FB6-AB8D-56DA3D1BB93D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1B977662-654F-4FB6-AB8D-56DA3D1BB93D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1B977662-654F-4FB6-AB8D-56DA3D1BB93D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,16 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "please_build-formatter", "please_build-formatter.csproj", "{CFC72DCC-8B8F-4E36-8679-478DB84CE9F0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{CFC72DCC-8B8F-4E36-8679-478DB84CE9F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CFC72DCC-8B8F-4E36-8679-478DB84CE9F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CFC72DCC-8B8F-4E36-8679-478DB84CE9F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CFC72DCC-8B8F-4E36-8679-478DB84CE9F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Loading…
Reference in New Issue
Block a user