From ab65c30ce635dc5abad245d5b3ef1d04b1d587f6 Mon Sep 17 00:00:00 2001 From: high Date: Sat, 31 Dec 2011 19:10:17 -0500 Subject: [PATCH] Added -dump switch which dumps permissions/config options Dumps are now alphabetical. --- TShockAPI/ConfigFile.cs | 4 ++-- TShockAPI/Permissions.cs | 6 +++--- TShockAPI/TShock.cs | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index f4e8a8a4..2d364217 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -236,12 +236,12 @@ namespace TShockAPI public static Action ConfigRead; - private static void DumpDescriptions() + public static void DumpDescriptions() { var sb = new StringBuilder(); var defaults = new ConfigFile(); - foreach (var field in defaults.GetType().GetFields()) + foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name)) { if (field.IsStatic) continue; diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 449e556d..87caffb7 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -148,10 +148,10 @@ namespace TShockAPI return Commands.ChatCommands.Where(c => c.Permission == perm).ToList(); } - private static void DumpDescriptions() + public static void DumpDescriptions() { var sb = new StringBuilder(); - foreach (var field in typeof (Permissions).GetFields()) + foreach (var field in typeof(Permissions).GetFields().OrderBy(f => f.Name)) { var name = field.Name; @@ -172,7 +172,7 @@ namespace TShockAPI c => c.Name + (c.Names.Count > 1 ? "({0})".SFormat(string.Join(" ", c.Names.ToArray(), 1, c.Names.Count - 1)) : "")); - sb.AppendLine("## {0} ".SFormat(name)); + sb.AppendLine("## {0} ".SFormat(name)); sb.AppendLine("**Description:** {0} ".SFormat(desc)); sb.AppendLine("**Commands:** {0} ".SFormat(strs.Count() > 0 ? string.Join(" ", strs) : "None")); sb.AppendLine(); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index f80b1cfc..70d1dc71 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -357,6 +357,11 @@ namespace TShockAPI Log.ConsoleInfo("World path has been set to " + path); } } + if (parms[i].ToLower() == "-dump") + { + ConfigFile.DumpDescriptions(); + Permissions.DumpDescriptions(); + } } }