예제 #1
0
 public void help(string strCmd)
 {
     if (pLuaFuncs.ContainsKey(strCmd))
     {
         Console.WriteLine(pLuaFuncs[strCmd].getFuncFullDoc());
     }
     else if (strCmd.IndexOf(".") == -1)
     {
         if (pLuaPackages.ContainsKey(strCmd))
         {
             ((LuaPackageDescriptor)pLuaPackages[strCmd]).WriteHelp();
         }
         else
         {
             Console.WriteLine("No such function or package: " + strCmd);
         }
     }
     else
     {
         string[] strArray = strCmd.Split(new char[] { '.' });
         if (!pLuaPackages.ContainsKey(strArray[0]))
         {
             Console.WriteLine("No such function or package: " + strCmd);
         }
         else
         {
             LuaPackageDescriptor descriptor3 = (LuaPackageDescriptor)pLuaPackages[strArray[0]];
             if (!descriptor3.HasFunc(strArray[1]))
             {
                 Console.WriteLine("Package " + strArray[0] + " doesn't have a " + strArray[1] + " function.");
             }
             else
             {
                 descriptor3.WriteHelp(strArray[1]);
             }
         }
     }
 }
예제 #2
0
        public void Help(string command)
        {
            // Check if the command is a function name
            if (_lua.Functions.Contains(command))
            {
                LuaFunctionDescriptor func = (LuaFunctionDescriptor)_lua.Functions[command];

                // Display basic help message
                txtResult.Text += "Help for " + command + ":\n=========";

                for (int i = 0; i <= command.Length; i++)
                {
                    txtResult.Text += "=";
                }

                txtResult.Text += "\n" + func.FunctionFullDocumentation + "\n\n";

                return;
            }

            // Check if the command is a package name
            if (command.IndexOf(".") == -1)
            {
                // Check if the package exists
                if (_lua.Packages.ContainsKey(command))
                {
                    LuaPackageDescriptor pkg = (LuaPackageDescriptor)_lua.Packages[command];

                    DisplayPackageHelp(pkg);

                    return;
                }
                else
                {
                    txtResult.Text += "No such function or package: " + command + "\n\n";

                    return;
                }
            }

            // Determine the path to the function name
            string[] parts = command.Split('.');

            // Check if the package exists
            if (!_lua.Packages.ContainsKey(parts[0]))
            {
                txtResult.Text += "No such function or package: " + command + "\n\n";

                return;
            }

            LuaPackageDescriptor desc = (LuaPackageDescriptor)_lua.Packages[parts[0]];

            // Check if the function exists within the package
            if (!desc.HasFunction(parts[1]))
            {
                txtResult.Text += "Package " + parts[0] + " doesn't have a " + parts[1] + " function.\n\n";

                return;
            }

            // Display basic help message
            txtResult.Text += "Help for " + command + ":\n=========";

            for (int i = 0; i <= command.Length; i++)
            {
                txtResult.Text += "=";
            }

            txtResult.Text += "\n" + desc.PackageName + "." + desc.WriteHelp(parts[1]) + "\n\n";
        }