From 9a2d29d320283038ad5cc37d7705b6d38dbbb077 Mon Sep 17 00:00:00 2001 From: timerix Date: Fri, 7 Apr 2023 21:08:36 +0600 Subject: [PATCH] code cleanup --- diff-text/Program.cs | 25 ++++++++++++++----------- paradox-mod-merger/Diff.cs | 7 ++----- paradox-mod-merger/Merge.cs | 11 ++++------- paradox-mod-merger/Program.cs | 11 ++++++----- paradox-mod-merger/Workshop.cs | 9 ++------- 5 files changed, 28 insertions(+), 35 deletions(-) diff --git a/diff-text/Program.cs b/diff-text/Program.cs index fc7bc80..7648448 100644 --- a/diff-text/Program.cs +++ b/diff-text/Program.cs @@ -26,17 +26,20 @@ public static class DiffText List? 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"); diff --git a/paradox-mod-merger/Diff.cs b/paradox-mod-merger/Diff.cs index f4f01da..21a9c5e 100644 --- a/paradox-mod-merger/Diff.cs +++ b/paradox-mod-merger/Diff.cs @@ -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) diff --git a/paradox-mod-merger/Merge.cs b/paradox-mod-merger/Merge.cs index 60e0693..81c48c4 100644 --- a/paradox-mod-merger/Merge.cs +++ b/paradox-mod-merger/Merge.cs @@ -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 added_mods = new List(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)) diff --git a/paradox-mod-merger/Program.cs b/paradox-mod-merger/Program.cs index ae7d2a9..bae5695 100644 --- a/paradox-mod-merger/Program.cs +++ b/paradox-mod-merger/Program.cs @@ -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; } diff --git a/paradox-mod-merger/Workshop.cs b/paradox-mod-merger/Workshop.cs index 2662142..ffb3bc8 100644 --- a/paradox-mod-merger/Workshop.cs +++ b/paradox-mod-merger/Workshop.cs @@ -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)