1
0
Fork 0
mirror of https://github.com/ppy/osu-tools.git synced 2025-06-11 18:20:35 +09:00

Make processor accept folder as argument

This commit is contained in:
smoogipoo 2018-05-15 13:13:06 +09:00
parent 99762f0da0
commit b40d3f56a9
2 changed files with 19 additions and 4 deletions

View file

@ -11,9 +11,9 @@ namespace PerformanceCalculator.Difficulty
public class DifficultyCommand : ProcessorCommand
{
[UsedImplicitly]
[Required, FileExists]
[Argument(0, Name = "beatmap", Description = "Required. The beatmap file (.osu) to compute the difficulty for.")]
public string Beatmap { get; }
[Required, FileOrDirectoryExists]
[Argument(0, Name = "path", Description = "Required. A beatmap file (.osu), or a folder containing .osu files to compute the difficulty for.")]
public string Path { get; }
[UsedImplicitly]
[Option(CommandOptionType.SingleOrNoValue, Template = "-r|--ruleset:<ruleset-id>", Description = "Optional. The ruleset to compute the beatmap difficulty for, if it's a convertible beatmap.\n"

View file

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using McMaster.Extensions.CommandLineUtils;
using osu.Game.Beatmaps;
@ -26,8 +27,22 @@ namespace PerformanceCalculator.Difficulty
protected override void Execute()
{
var beatmap = new ProcessorWorkingBeatmap(command.Beatmap);
if (Directory.Exists(command.Path))
{
foreach (string file in Directory.GetFiles(command.Path, "*.osu", SearchOption.AllDirectories))
{
var beatmap = new ProcessorWorkingBeatmap(file);
command.Console.WriteLine(beatmap.BeatmapInfo.ToString());
processBeatmap(beatmap);
}
}
else
processBeatmap(new ProcessorWorkingBeatmap(command.Path));
}
private void processBeatmap(WorkingBeatmap beatmap)
{
// Get the ruleset
var ruleset = getRuleset(command.Ruleset ?? beatmap.BeatmapInfo.RulesetID);