diff --git a/Quaver.Tools/Commands/AutoModComand.cs b/Quaver.Tools/Commands/AutoModComand.cs new file mode 100644 index 000000000..49832ac2f --- /dev/null +++ b/Quaver.Tools/Commands/AutoModComand.cs @@ -0,0 +1,43 @@ +using System; +using System.IO; +using System.Linq; +using Newtonsoft.Json.Linq; +using Quaver.API.Maps; +using Quaver.API.Maps.AutoMod; + +namespace Quaver.Tools.Commands +{ + public class AutoModCommand : Command + { + private string Dir { get; } + + public AutoModCommand(string[] args) : base(args) + { + var list = args.ToList(); + list.RemoveAt(0); + Dir = string.Join(' ', list); + } + + public override void Execute() + { + var totalIssues = 0; + + foreach (var file in Directory.GetFiles(Dir)) + { + if (Path.GetExtension(file) != ".qua") + continue; + + var qua = Qua.Parse(file); + var automod = new AutoMod(qua); + automod.Run(); + + totalIssues += automod.Issues.Count; + } + + Console.WriteLine(JObject.FromObject(new + { + HasIssues = totalIssues > 0 + })); + } + } +} \ No newline at end of file diff --git a/Quaver.Tools/Program.cs b/Quaver.Tools/Program.cs index 0e44079b4..29f42c614 100644 --- a/Quaver.Tools/Program.cs +++ b/Quaver.Tools/Program.cs @@ -28,7 +28,8 @@ internal static void Main(string[] args) $"-convertosu \n" + $"-convertsm \n" + $"-changequaids \n" + - $"-recalculate Recalculates a given user's top 50 scores for a game mode."); + $"-recalculate Recalculates a given user's top 50 scores for a game mode.\n" + + $"-automod Runs AutoMod on all files in a .qua directory and returns if there are any issues."); return; } @@ -64,6 +65,9 @@ internal static void Main(string[] args) case "-recalculate": new RecalculateCommand(args).Execute(); break; + case "-automod": + new AutoModCommand(args).Execute(); + break; default: throw new ArgumentException(); }