Fix checking repository path argument

This commit is contained in:
Adison Cavani 2021-10-09 21:44:04 +02:00
parent ee1ce5188a
commit 8c2aedad45
No known key found for this signature in database
GPG key ID: 2C36C61283E73DC9

View file

@ -12,19 +12,16 @@ namespace DistroGrubThemes
{
var parser = new Parser(with => with.HelpWriter = null);
var parserResult = parser.ParseArguments<ProgramOptions>(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;
}
}
}