Merge pull request #9397 from Herve-M/feat-utility-polish

Add basic arguments validation
This commit is contained in:
Oliver Brakmann
2015-10-06 19:23:23 +02:00
24 changed files with 146 additions and 53 deletions

View File

@@ -9,12 +9,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using OpenRA.FileSystem;
using OpenRA.Traits;
using StyleCop;
namespace OpenRA.Mods.Common.UtilityCommands
@@ -24,6 +19,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
public string Name { get { return "--check-code-style"; } }
int violationCount;
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("DIRECTORY", "Check the *.cs source code files in a directory for code style violations.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -9,14 +9,9 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using OpenRA.FileSystem;
using OpenRA.Graphics;
using OpenRA.Traits;
using StyleCop;
namespace OpenRA.Mods.Common.UtilityCommands
{
@@ -24,6 +19,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--check-sequence-sprites"; } }
public bool ValidateArguments(string[] args)
{
return true;
}
[Desc("Check the sequence definitions for missing sprite files.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.UtilityCommands
@@ -34,6 +33,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
Console.WriteLine("OpenRA.Utility(1,1): Warning: {0}", e);
}
public bool ValidateArguments(string[] args)
{
return true;
}
[Desc("[MAPFILE]", "Check a mod or map for certain yaml errors.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -15,7 +15,6 @@ using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using OpenRA.FileFormats;
using OpenRA.Mods.Common.SpriteLoaders;
@@ -25,6 +24,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--shp"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("PNGFILE [PNGFILE ...]", "Combine a list of PNG images into a SHP")]
public void Run(ModData modData, string[] args)
{

View File

@@ -9,14 +9,11 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using OpenRA.FileFormats;
using OpenRA.Graphics;
namespace OpenRA.Mods.Common.UtilityCommands
@@ -25,6 +22,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--png"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 3;
}
[Desc("SPRITEFILE PALETTE [--noshadow] [--nopadding]",
"Convert a shp/tmp/R8 to a series of PNGs, optionally removing shadow")]
public void Run(ModData modData, string[] args)

View File

@@ -17,6 +17,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--man-page"; } }
public bool ValidateArguments(string[] args)
{
return true;
}
[Desc("Create a man page in troff format.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Data;
using System.Text;

View File

@@ -9,10 +9,8 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using OpenRA.FileSystem;
namespace OpenRA.Mods.Common.UtilityCommands
@@ -21,6 +19,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--extract"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("Extract files from mod packages to the current directory")]
public void Run(ModData modData, string[] args)
{

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace OpenRA.Mods.Common.UtilityCommands
{
@@ -20,6 +19,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--extract-language-strings"; } }
public bool ValidateArguments(string[] args)
{
return true;
}
[Desc("Extract translatable strings that are not yet localized and update chrome layout.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -21,6 +21,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--lua-docs"; } }
public bool ValidateArguments(string[] args)
{
return true;
}
[Desc("Generate Lua API documentation in MarkDown format.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -20,6 +20,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--docs"; } }
public bool ValidateArguments(string[] args)
{
return true;
}
[Desc("Generate trait documentation in MarkDown format.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -9,15 +9,12 @@
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using OpenRA.FileSystem;
using OpenRA.Graphics;
using OpenRA.Traits;
using StyleCop;
namespace OpenRA.Mods.Common.UtilityCommands
{
@@ -25,6 +22,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--fix-classic-tilesets"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("EXTENSIONS", "Fixes missing template tile definitions and adds filename extensions.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -9,10 +9,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using OpenRA.FileSystem;
using OpenRA.Graphics;
@@ -22,6 +19,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--map-preview"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("MAPFILE", "Render PNG minimap of specified oramap file.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -9,9 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRA.Mods.Common.UtilityCommands
{
@@ -19,6 +16,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--map-hash"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("MAPFILE", "Generate hash of specified oramap file.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -17,6 +17,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--map-import"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("FILENAME", "Convert a legacy INI/MPR map to the OpenRA format.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -10,8 +10,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

View File

@@ -13,8 +13,6 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.Graphics;
using OpenRA.Mods.Common.SpriteLoaders;
@@ -26,6 +24,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--remap"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 5;
}
[Desc("SRCMOD:PAL DESTMOD:PAL SRCSHP DESTSHP", "Remap SHPs to another palette")]
public void Run(ModData modData, string[] args)
{

View File

@@ -18,6 +18,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--replay-metadata"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("REPLAYFILE", "Print the game metadata from a replay file.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -8,17 +8,17 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRA.Mods.Common.UtilityCommands
{
class UpgradeMapCommand : IUtilityCommand
{
public string Name { get { return "--upgrade-map"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 3;
}
[Desc("MAP", "CURRENTENGINE", "Upgrade map rules to the latest engine version.")]
public void Run(ModData modData, string[] args)
{

View File

@@ -9,10 +9,8 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace OpenRA.Mods.Common.UtilityCommands
{
@@ -20,6 +18,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
public string Name { get { return "--upgrade-mod"; } }
public bool ValidateArguments(string[] args)
{
return args.Length >= 2;
}
[Desc("CURRENTENGINE", "Upgrade mod rules to the latest engine version.")]
public void Run(ModData modData, string[] args)
{