From 4e52b9391291aeb8f76703c1ac317d13ea47370b Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 6 Mar 2017 18:58:06 -0500 Subject: [PATCH] sos.help indexes non-engine commands now --- ShiftOS_TheReturn/Commands.cs | 89 ++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 9bc876f..76aa42f 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -367,68 +367,79 @@ namespace ShiftOS.Engine [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help() { - var asm = Assembly.GetExecutingAssembly(); - - var types = asm.GetTypes(); - - foreach (var type in types) + foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) { - if (Shiftorium.UpgradeAttributesUnlocked(type)) + if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) { - foreach (var a in type.GetCustomAttributes(false)) + try { - if (a is Namespace) + var asm = Assembly.LoadFile(exec); + + var types = asm.GetTypes(); + + foreach (var type in types) { - var ns = a as Namespace; - - if (!ns.hide) + if (Shiftorium.UpgradeAttributesUnlocked(type)) { - string descp = "{NAMESPACE_" + ns.name.ToUpper() + "_DESCRIPTION}"; - if (descp == Localization.Parse(descp)) - descp = ""; - else - descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; - - Console.WriteLine($"{{NAMESPACE}}{ns.name}" + descp); - - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + foreach (var a in type.GetCustomAttributes(false)) { - if (Shiftorium.UpgradeAttributesUnlocked(method)) + if (a is Namespace) { - foreach (var ma in method.GetCustomAttributes(false)) + var ns = a as Namespace; + + if (!ns.hide) { - if (ma is Command) + string descp = "{NAMESPACE_" + ns.name.ToUpper() + "_DESCRIPTION}"; + if (descp == Localization.Parse(descp)) + descp = ""; + else + descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; + + Console.WriteLine($"{{NAMESPACE}}{ns.name}" + descp); + + foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - var cmd = ma as Command; - - if (!cmd.hide) + if (Shiftorium.UpgradeAttributesUnlocked(method)) { - string descriptionparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (descriptionparse == Localization.Parse(descriptionparse)) - descriptionparse = ""; - else - descriptionparse = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descriptionparse) : ""; + foreach (var ma in method.GetCustomAttributes(false)) + { + if (ma is Command) + { + var cmd = ma as Command; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{SEPERATOR}" + usageparse, new Dictionary() { + if (!cmd.hide) + { + string descriptionparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; + string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; + if (descriptionparse == Localization.Parse(descriptionparse)) + descriptionparse = ""; + else + descriptionparse = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descriptionparse) : ""; + + if (usageparse == Localization.Parse(usageparse)) + usageparse = ""; + else + usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{SEPERATOR}" + usageparse, new Dictionary() { {"%ns", ns.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine($"{{COMMAND}}{ns.name}.{cmd.name}" + usageparse + descriptionparse); + Console.WriteLine($"{{COMMAND}}{ns.name}.{cmd.name}" + usageparse + descriptionparse); + } + } + } } + } } - } + } } } - } + } + catch { } } }