This commit is contained in:
Timerix22 2023-02-04 03:15:52 +06:00
parent 1ab9a50019
commit 2d257200fe
9 changed files with 35 additions and 20 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib.Dtsod</PackageId>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<Authors>Timerix</Authors>
<Description>Definitely not json</Description>
<RepositoryType>GIT</RepositoryType>
@ -33,7 +33,7 @@
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib" Version="1.0.2" />
<PackageReference Include="DTLib" Version="1.0.4" />
</ItemGroup>
<!--project files-->

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib.Logging</PackageId>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<Authors>Timerix</Authors>
<Description>Loggers with dependency injection</Description>
<RepositoryType>GIT</RepositoryType>
@ -30,7 +30,7 @@
<ProjectReference Include="..\DTLib.Ben.Demystifier\DTLib.Ben.Demystifier.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib" Version="1.0.2" />
<PackageReference Include="DTLib" Version="1.0.4" />
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.2" />
</ItemGroup>
</Project>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib.Network</PackageId>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<Authors>Timerix</Authors>
<Description>Some sick network protocols</Description>
<RepositoryType>GIT</RepositoryType>
@ -32,6 +32,6 @@
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib.Dtsod" Version="1.0.3" />
<PackageReference Include="DTLib.Dtsod" Version="1.0.4" />
</ItemGroup>
</Project>

View File

@ -27,8 +27,10 @@
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib.Network" Version="1.0.3" />
<PackageReference Include="DTLib.Logging" Version="1.0.7" />
<PackageReference Include="DTLib" Version="1.0.4" />
<PackageReference Include="DTLib.Dtsod" Version="1.0.4" />
<PackageReference Include="DTLib.Network" Version="1.0.4" />
<PackageReference Include="DTLib.Logging" Version="1.0.8" />
</ItemGroup>
<!--project files-->

View File

@ -10,6 +10,7 @@ global using DTLib.Filesystem;
global using DTLib.Dtsod;
global using static DTLib.Tests.TesterLog;
global using static DTLib.Tests.Program;
using DTLib.Console;
using DTLib.Logging.New;
namespace DTLib.Tests;
@ -18,7 +19,7 @@ public static class Program
{
public static Logging.ConsoleLogger OldLogger = new("logs", "DTLib.Tests");
public static ILogger Logger;
public static void Main()
public static void Main(string[] args)
{
System.Console.OutputEncoding = Encoding.UTF8;
System.Console.InputEncoding = Encoding.UTF8;
@ -29,11 +30,14 @@ public static class Program
try
{
new LaunchArgumentParser().WithNoExit().ParseAndHandle(args);
TestPInvoke.TestAll();
TestAutoarr.TestAll();
TestDtsodV23.TestAll();
TestDtsodV24.TestAll();
}
catch(LaunchArgumentParser.ExitAfterHelpException)
{ }
catch (Exception ex)
{ mainContext.LogError(ex); }

View File

@ -23,7 +23,7 @@ public class LaunchArgumentParser
public string CreateHelpArgMessage(string argAlias)
{
StringBuilder b = new();
var arg = Get(argAlias);
var arg = Parse(argAlias);
arg.AppendHelpInfo(b);
return b.ToString();
}
@ -51,6 +51,12 @@ public class LaunchArgumentParser
Add(helpArg);
}
public LaunchArgumentParser WithNoExit()
{
ExitIfNoArgs = false;
return this;
}
public LaunchArgumentParser(ICollection<LaunchArgument> arguments) : this()
{
foreach (var arg in arguments)
@ -69,7 +75,7 @@ public class LaunchArgumentParser
argDict.Add(arg.Aliases[a], arg);
}
public LaunchArgument Get(string argAlias)
public LaunchArgument Parse(string argAlias)
{
// different argument providing patterns
if (!argDict.TryGetValue(argAlias, out var arg) && // arg
@ -90,10 +96,12 @@ public class LaunchArgumentParser
// show help and throw
if (args.Length == 0 && ExitIfNoArgs)
HelpHandler();
List<LaunchArgument> execQueue = new();
for (int i = 0; i < args.Length; i++)
{
LaunchArgument arg = Get(args[i]);
LaunchArgument arg = Parse(args[i]);
if (arg.HandlerWithArg is not null)
{
@ -103,14 +111,14 @@ public class LaunchArgumentParser
arg.Handler = () => arg.HandlerWithArg(args[i]);
}
else if (arg.Handler is null) throw new NullReferenceException($"argument <{args[i]}> hasn't got any handlers");
execQueue.Add(arg);
}
// ascending sort by priority
argList.Sort((a0, a1) => a0.Priority-a1.Priority);
execQueue.Sort((a0, a1) => a0.Priority-a1.Priority);
// finally executing handlers
foreach (var a in argList)
{
foreach (var a in execQueue)
a.Handler!();
}
}
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<!--package info-->
<PackageId>DTLib</PackageId>
<Version>1.0.3</Version>
<Version>1.0.4</Version>
<Authors>Timerix</Authors>
<Description>Library for all my C# projects</Description>
<RepositoryType>GIT</RepositoryType>

View File

@ -1,4 +1,5 @@
using System.Threading;
using DTLib.Console;
namespace DTLib.Experimental
{

View File

@ -1,7 +1,7 @@
#!/usr/bin/bash
set -ex
dotnet pack -c Release -o ./nuget_new/
rm ./nuget_new/DTLib.Tests.*
rm -rf nuget
mkdir nuget
dotnet pack -c Release -o ./nuget/
rm ./nuget/DTLib.Tests.*
mv nuget_new nuget
ls nuget