diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
commit | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch) | |
tree | c3b34ccb2737e347a73768536895cbbaab13cc01 /dsa/DSALib/Commands/Help.cs | |
parent | ec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff) | |
parent | af74efccf8d21e6151022b71f3cacd3fa83024ee (diff) |
Merge branch 'rework-backend'
Diffstat (limited to 'dsa/DSALib/Commands/Help.cs')
-rw-r--r-- | dsa/DSALib/Commands/Help.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/dsa/DSALib/Commands/Help.cs b/dsa/DSALib/Commands/Help.cs new file mode 100644 index 0000000..4506821 --- /dev/null +++ b/dsa/DSALib/Commands/Help.cs @@ -0,0 +1,54 @@ +using System.Linq; +using DSALib.Auxiliary; +using DSALib.DSA_Game.Save; + +namespace DSALib.Commands +{ + public class Help + { + //public static List<CommandInfo> Commands { get; } = new List<CommandInfo>(); + + + public static string Get_Specific_Help(string command) + { + // return command specific help + var com = Properties.CommandInfos + .OrderBy(x => SpellCorrect.Compare(x.Name, command.ToLower())).Last(); // get best fit command + return com.GetDescription(); + } + + public static string Get_Generic_Help() + { + var res = ""; + foreach (var com in Properties.CommandInfos) + { + var first_column_width = 8; + res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief; + + if (com.Description.Length > 1) + res += "\n" + "".AddSpaces(first_column_width) + "(\"!man " + com.Name + + "\" gibt genauere Informationen)"; + + res += "\n\n"; + } + + return res; + } + + public static string ShowHelp(params string[] commandList) + { + var command = ""; + if (commandList.Length > 0) command = commandList.Aggregate((s, c) => s + " " + c); + + if (command.Equals(string.Empty)) // return generic Help + { + var res = Get_Generic_Help(); + + return res; + } + + + return Get_Specific_Help(command); + } + } +}
\ No newline at end of file |