From 0e545a3fa4c5e1d61b549ab0e931e1acea2ff95b Mon Sep 17 00:00:00 2001 From: KeelMatrix Date: Sat, 6 Jun 2026 06:27:16 +0500 Subject: [PATCH 1/2] Add recent path history setting --- RepoDumpKit/AppSettings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RepoDumpKit/AppSettings.cs b/RepoDumpKit/AppSettings.cs index 9d6f7b8..e821f93 100644 --- a/RepoDumpKit/AppSettings.cs +++ b/RepoDumpKit/AppSettings.cs @@ -7,6 +7,7 @@ internal static class AppSettings public const string PreservedGitIgnoredCommand = "/d /c \"(git ls-files --cached & git ls-files -o -i --exclude-standard) ^| git check-ignore --no-index --stdin\""; + public const int MaxSavedSolutionPaths = 10; public const int MaxTreeEntriesPerDirectory = 80; public const int MaxTreeDepth = 16; public const int MaxIgnoredPathsPerRenderedSubtree = 250; From 9c1d9099c743147c8478d8f9996287a8874902b3 Mon Sep 17 00:00:00 2001 From: KeelMatrix Date: Sat, 6 Jun 2026 06:27:35 +0500 Subject: [PATCH 2/2] Add recent path history selection --- RepoDumpKit/SolutionPathService.cs | 107 ++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 23 deletions(-) diff --git a/RepoDumpKit/SolutionPathService.cs b/RepoDumpKit/SolutionPathService.cs index f7cbfcb..960a3ba 100644 --- a/RepoDumpKit/SolutionPathService.cs +++ b/RepoDumpKit/SolutionPathService.cs @@ -20,29 +20,45 @@ public static string GetSolutionPath(string[] args) return argumentPath; } - string? existingPath = ReadSavedPath(configFilePath); + IReadOnlyList savedPaths = ReadSavedPaths(configFilePath); - if (!string.IsNullOrWhiteSpace(existingPath)) + if (savedPaths.Count > 0) { - Console.WriteLine($"Saved path: {existingPath}"); - Console.Write("Press Enter to use it, or type a new path: "); - string? typed = Console.ReadLine(); + Console.WriteLine("Recent paths:"); - if (string.IsNullOrWhiteSpace(typed)) + for (int index = 0; index < savedPaths.Count; index++) { - return existingPath; + Console.WriteLine($"{index + 1}. {savedPaths[index]}"); } - string newTyped = typed.Trim(); + Console.Write("Choose a number, press Enter for 1, or paste a new path: "); - while (!Directory.Exists(newTyped)) + while (true) { - Console.Write("Invalid path. Enter a valid full path: "); - newTyped = (Console.ReadLine() ?? string.Empty).Trim(); + string typed = (Console.ReadLine() ?? string.Empty).Trim(); + string selectedPath; + + if (string.IsNullOrWhiteSpace(typed)) + { + selectedPath = savedPaths[0]; + } + else if (TryGetSavedPathByNumber(typed, savedPaths, out string? savedPath)) + { + selectedPath = savedPath; + } + else + { + selectedPath = typed; + } + + if (Directory.Exists(selectedPath)) + { + SavePath(configFilePath, selectedPath); + return selectedPath; + } + + Console.Write("Invalid path. Choose a listed number or enter a valid full path: "); } - - SavePath(configFilePath, newTyped); - return newTyped; } while (true) @@ -60,37 +76,82 @@ public static string GetSolutionPath(string[] args) } } - private static string? ReadSavedPath(string configFilePath) + private static IReadOnlyList ReadSavedPaths(string configFilePath) { if (!File.Exists(configFilePath)) { - return null; + return []; } try { - string existingPath = File.ReadAllText(configFilePath).Trim(); + string[] storedPaths = File.ReadAllLines(configFilePath); + List validPaths = []; + HashSet seenPaths = new(AppSettings.PathComparer); - if (Directory.Exists(existingPath)) + foreach (string storedPath in storedPaths) { - return existingPath; + string path = storedPath.Trim(); + + if (string.IsNullOrWhiteSpace(path) || !seenPaths.Add(path)) + { + continue; + } + + if (Directory.Exists(path)) + { + validPaths.Add(path); + + if (validPaths.Count == AppSettings.MaxSavedSolutionPaths) + { + break; + } + } + else + { + Console.WriteLine($"Stored path '{path}' not found or is invalid."); + } } - Console.WriteLine($"Stored path '{existingPath}' not found or is invalid."); - return null; + return validPaths; } catch (Exception ex) { Console.WriteLine($"Error reading config file: {ex.GetType().Name}: {ex.Message}"); - return null; + return []; } } + private static bool TryGetSavedPathByNumber(string input, IReadOnlyList savedPaths, out string? savedPath) + { + savedPath = null; + + if (!int.TryParse(input, out int selectedNumber)) + { + return false; + } + + if (selectedNumber < 1 || selectedNumber > savedPaths.Count) + { + return false; + } + + savedPath = savedPaths[selectedNumber - 1]; + return true; + } + private static void SavePath(string configFilePath, string path) { try { - File.WriteAllText(configFilePath, path); + string fullPath = Path.GetFullPath(path.Trim()); + List savedPaths = ReadSavedPaths(configFilePath) + .Where(savedPath => !string.Equals(savedPath, fullPath, AppSettings.PathComparison)) + .Prepend(fullPath) + .Take(AppSettings.MaxSavedSolutionPaths) + .ToList(); + + File.WriteAllLines(configFilePath, savedPaths); Console.WriteLine($"Path saved to {configFilePath}"); } catch (Exception ex)