diff --git a/Program.cs b/Program.cs index b4a8c8c..bb81872 100644 --- a/Program.cs +++ b/Program.cs @@ -7,9 +7,12 @@ } else { switch (args[0]) { case "determinePacmanCacheDirectory": - Pacserver.determinePacmanCacheDirectory(); + Console.WriteLine(Pacserver.determinePacmanCacheDirectory()); break; default: + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Possible options are: determinePacmanCacheDirectory"); + Console.ResetColor(); break; } } diff --git a/pacserver.cs b/pacserver.cs index 1dbf462..5ebad7e 100644 --- a/pacserver.cs +++ b/pacserver.cs @@ -3,7 +3,7 @@ using System.Text.RegularExpressions; public class Pacserver { public static string pacmanCacheDirectory { get; set; } = string.Empty; public static string determinePacmanCacheDirectory() { - // string defaultPacmanCacheDirectory = "/var/cache/pacman/pkg/"; + string defaultPacmanCacheDirectory = "/var/cache/pacman/pkg/"; Regex regex = new Regex(@"\/(?:[\w.-]+\/)*[\w.-]+(?:\.\w+)*\/?$"); // https://regex101.com/r/GwWeui/2 string? line; @@ -13,7 +13,11 @@ public class Pacserver { Match match = regex.Match(line); if (match.Success) { pacmanCacheDirectory = match.ToString(); + } else { + throw new Exception("Could not determine where pacman cache is! Would normally be found here " + defaultPacmanCacheDirectory); } + } else { + throw new Exception("Pacman config has no CacheDir specified!"); } } file.Close();