diff options
| author | Michael <[email protected]> | 2017-05-24 10:03:36 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-24 10:03:36 -0400 |
| commit | 9764bfd2aa55835246ebd2328bcdd436950f733e (patch) | |
| tree | c7b66acccf5f59ec4501bf99b0bf2914f40318ac /ShiftOS_TheReturn | |
| parent | 44a4de1c173a0ab88ff3aa519b3a25888f2eff85 (diff) | |
| download | shiftos_thereturn-9764bfd2aa55835246ebd2328bcdd436950f733e.tar.gz shiftos_thereturn-9764bfd2aa55835246ebd2328bcdd436950f733e.tar.bz2 shiftos_thereturn-9764bfd2aa55835246ebd2328bcdd436950f733e.zip | |
revamp sos.help a little
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/Commands.cs | 128 |
1 files changed, 84 insertions, 44 deletions
diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 6e59311..c2005f2 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -450,80 +450,120 @@ namespace ShiftOS.Engine } } - [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] - public static bool Help() + [Command("help", "{COMMAND_HELP_USAGE", "{COMMAND_HELP_DESCRIPTION}")] + public static bool Help(Dictionary<string, object> args) { - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + Console.WriteLine("Retrieving help data..."); + if (args.ContainsKey("ns")) { - if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) + if (args["ns"] is string) { - try + string ns = args["ns"].ToString(); + bool foundNS = false; + foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) { - var asm = Assembly.LoadFile(exec); - - var types = asm.GetTypes(); - - foreach (var type in types) + if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) { - if (Shiftorium.UpgradeAttributesUnlocked(type)) + try { - foreach (var a in type.GetCustomAttributes(false)) + var asm = Assembly.LoadFile(exec); + + var types = asm.GetTypes(); + + foreach (var type in types) { - if (a is Namespace) + if (Shiftorium.UpgradeAttributesUnlocked(type)) { - var ns = a as Namespace; + var nsa = (Namespace)type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace && (x as Namespace).name == ns); - if (!ns.hide) + if (nsa != null) { - 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)) + if (!nsa.hide) { - if (Shiftorium.UpgradeAttributesUnlocked(method)) + foundNS = true; + string descp = "{NAMESPACE_" + nsa.name.ToUpper() + "_DESCRIPTION}"; + if (descp == Localization.Parse(descp)) + descp = ""; + else + descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; + + Console.WriteLine($"{{NAMESPACE}}{nsa.name}" + descp); + + foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (Shiftorium.UpgradeAttributesUnlocked(method)) { - if (ma is Command) + foreach (var ma in method.GetCustomAttributes(false)) { - var cmd = ma as Command; - - if (!cmd.hide) + if (ma is Command) { - 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<string, string>() { - {"%ns", ns.name}, + var cmd = ma as Command; + + if (!cmd.hide) + { + string descriptionparse = "{COMMAND_" + nsa.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; + string usageparse = "{COMMAND_" + nsa.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<string, string>() { + {"%ns", nsa.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine($"{{COMMAND}}{ns.name}.{cmd.name}" + usageparse + descriptionparse); + Console.WriteLine($"{{COMMAND}}{nsa.name}.{cmd.name}" + usageparse + descriptionparse); + } } } } - } + } } } - } } + } + + + + + catch { } } + } + if (foundNS == false) + { + Console.WriteLine("Error: Namespace not found! Couldn't retrieve help info."); + } + + } + return true; + } + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes()) + { + Namespace ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; + if(ns != null) + { + if(!ns.hide) + { + Console.WriteLine("sos.help{ns:\"" + ns.name + "\"}"); + } + } + } } catch { } } |
