From 8c2aedad45b55feced8d6ec7aa20fa7780295652 Mon Sep 17 00:00:00 2001 From: Adison Cavani Date: Sat, 9 Oct 2021 21:44:04 +0200 Subject: [PATCH] Fix checking repository path argument --- src/Program.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Program.cs b/src/Program.cs index 3f6f66a..7b62eed 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -12,19 +12,16 @@ namespace DistroGrubThemes { var parser = new Parser(with => with.HelpWriter = null); var parserResult = parser.ParseArguments(args); - parserResult.WithParsed(options => RunOptions(options)).WithNotParsed(errs => Help.DisplayHelp(parserResult, errs)); } static void RunOptions(ProgramOptions opts) { Program program = new Program(); - program.CheckRepoPath(opts.RepositoryPath); - program.UpdateAssets(opts.RepositoryPath); + string path = program.CheckRepoPath(opts.RepositoryPath); + program.UpdateAssets(path); } - - void UpdateAssets(string path) { UpdateIcons(path + @"\assets\icons", path + @"\customize"); @@ -33,7 +30,7 @@ namespace DistroGrubThemes void UpdateIcons(string iconsPath, string customizePath) { - Console.Write("Updating icons ... "); + Console.Write("\nUpdating icons ... "); var icons = FilesArray(iconsPath); foreach (var directory in CustomDirectories(customizePath)) @@ -77,12 +74,12 @@ namespace DistroGrubThemes return Directory.GetDirectories(customizePath); } - void CheckRepoPath(string path) + string CheckRepoPath(string path) { if (Directory.Exists(path) && path.Contains("distro-grub-themes")) { int index = path.IndexOf("distro-grub-themes") + 18; - path = path.Substring(0, index); + return path.Substring(0, index); } else @@ -92,6 +89,7 @@ namespace DistroGrubThemes Console.ResetColor(); Console.Write("could not find repository in this path"); Environment.Exit(1); + return null; } } }