-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from Quaver/automod-cmd
Add AutoMod command
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
})); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters