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; List<Diff>? diff = null;
bool noColors = false; bool noColors = false;
new LaunchArgumentParser( new LaunchArgumentParser(
new LaunchArgument(new[] { "s", "string" }, new LaunchArgument(new[] { "s", "string" },
"shows difference of two strings", "shows difference of two strings",
(s0, s1) => diff=TextDiff(s0, s1), (s0, s1) => diff=TextDiff(s0, s1),
"string0", "string1", 1), "string0", "string1",
new LaunchArgument(new[] { "f", "file" }, 1),
"shows difference of two text files", new LaunchArgument(new[] { "f", "file" },
(f0,f1) => diff=FileDiff(f0, f1), "shows difference of two text files",
"file0", "file1", 1), (f0,f1) => diff=FileDiff(f0, f1),
new LaunchArgument(new []{"p", "plain-text","no-colors"}, "file0", "file1",
"print diff in plain text format", 1),
()=> noColors=true, 0) new LaunchArgument(new []{"p", "plain-text","no-colors"},
"print diff in plain text format",
()=> noColors=true,
0)
).ParseAndHandle(args); ).ParseAndHandle(args);
if (diff == null) if (diff == null)
throw new Exception("no action specified: use -s or -f"); 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 diff_text;
using DTLib.Ben.Demystifier; using DTLib.Dtsod;
namespace ParadoxModMerger; namespace ParadoxModMerger;
@ -17,7 +14,7 @@ public record struct ConflictingModFile(string FilePath, string[] Mods);
static class Diff static class Diff
{ {
static ConsoleLogger logger = new($"logs", "diff"); static ConsoleLogger logger = new("logs", "diff");
static void Log(params string[] msg) => logger.Log(msg); static void Log(params string[] msg) => logger.Log(msg);
public static void DiffCommandHandler(string connected_pathes) public static void DiffCommandHandler(string connected_pathes)

View File

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

View File

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

View File

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