code cleanup

This commit is contained in:
timerix 2023-04-07 21:08:36 +06:00
parent e59dfec8b5
commit 9a2d29d320
5 changed files with 28 additions and 35 deletions

View File

@ -26,17 +26,20 @@ public static class DiffText
List<Diff>? diff = null;
bool noColors = false;
new LaunchArgumentParser(
new LaunchArgument(new[] { "s", "string" },
"shows difference of two strings",
(s0, s1) => diff=TextDiff(s0, s1),
"string0", "string1", 1),
new LaunchArgument(new[] { "f", "file" },
"shows difference of two text files",
(f0,f1) => diff=FileDiff(f0, f1),
"file0", "file1", 1),
new LaunchArgument(new []{"p", "plain-text","no-colors"},
"print diff in plain text format",
()=> noColors=true, 0)
new LaunchArgument(new[] { "s", "string" },
"shows difference of two strings",
(s0, s1) => diff=TextDiff(s0, s1),
"string0", "string1",
1),
new LaunchArgument(new[] { "f", "file" },
"shows difference of two text files",
(f0,f1) => diff=FileDiff(f0, f1),
"file0", "file1",
1),
new LaunchArgument(new []{"p", "plain-text","no-colors"},
"print diff in plain text format",
()=> noColors=true,
0)
).ParseAndHandle(args);
if (diff == null)
throw new Exception("no action specified: use -s or -f");

View File

@ -1,8 +1,5 @@
using System.Linq;
using DTLib.Console;
using DTLib.Dtsod;
using diff_text;
using DTLib.Ben.Demystifier;
using DTLib.Dtsod;
namespace ParadoxModMerger;
@ -17,7 +14,7 @@ public record struct ConflictingModFile(string FilePath, string[] Mods);
static class Diff
{
static ConsoleLogger logger = new($"logs", "diff");
static ConsoleLogger logger = new("logs", "diff");
static void Log(params string[] msg) => logger.Log(msg);
public static void DiffCommandHandler(string connected_pathes)

View File

@ -1,11 +1,8 @@
using System.Linq;
using DTLib.Console;
namespace ParadoxModMerger;
namespace ParadoxModMerger;
static class Merge
{
static ConsoleLogger logger = new($"logs", "merge");
static ConsoleLogger logger = new("logs", "merge");
static void Log(params string[] msg) => logger.Log(msg);
private const string modlist_filename = "modlist.txt";
@ -158,8 +155,8 @@ static class Merge
}
List<IOPath> added_mods = new List<IOPath>(src_dir_mods.Count - changed_mods.Count);
var found_mods = Enumerable
.Concat(changed_mods, unchanged_mods)
var found_mods = changed_mods
.Concat(unchanged_mods)
.Select(m=>Path.Concat(updated_mods_dir, m.LastName()))
.ToList();
foreach (var modD in Diff.DiffCollections(found_mods, src_dir_mods))

View File

@ -1,20 +1,21 @@
global using System;
global using System.Collections.Generic;
global using System.Diagnostics;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib;
global using DTLib.Extensions;
global using DTLib.Filesystem;
global using DTLib.Logging;
using System.Linq;
using System.Security.Cryptography;
using DTLib.Console;
global using DTLib.Ben.Demystifier;
global using DTLib.Console;
namespace ParadoxModMerger;
public static class Program
{
static ConsoleLogger logger = new($"logs", "main");
static ConsoleLogger logger = new("logs", "main");
static void Log(params string[] msg) => logger.Log(msg);
public static bool YesAll = false;
@ -95,7 +96,7 @@ public static class Program
{ }
catch (Exception ex)
{
Log("r", DTLib.Ben.Demystifier.ExceptionExtensions.ToStringDemystified(ex));
Log("r", ExceptionExtensions.ToStringDemystified(ex));
Console.ResetColor();
return 1;
}

View File

@ -1,17 +1,12 @@
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using DTLib.Ben.Demystifier;
using Fizzler.Systems.HtmlAgilityPack;
using HtmlAgilityPack;
namespace ParadoxModMerger;
using Fizzler.Systems.HtmlAgilityPack;
static class Workshop
{
static ConsoleLogger logger = new($"logs", "clear");
static ConsoleLogger logger = new("logs", "clear");
static void Log(params string[] msg) => logger.Log(msg);
public static void ClearWorkshop(IOPath workshopDir, IOPath outDir)