Update the "config get <section> <key>" command to "config get [<section>] [<key>]"
The config get command shows a current config value on the console. Now, if <key> is omitted then all the values for the given section are printed. If <section> is ommitted then all sections and all keys are printed. Current config can also be dumped to a file using "config save <path>". This can be handy for resolving or eliminating config issuesviewer-2-initial-appearance
parent
41105948bd
commit
cb14e1d272
|
@ -75,6 +75,11 @@ namespace OpenSim.Framework.Console
|
||||||
{
|
{
|
||||||
System.Console.WriteLine(text);
|
System.Console.WriteLine(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OutputFormat(string format, params string[] components)
|
||||||
|
{
|
||||||
|
Output(string.Format(format, components));
|
||||||
|
}
|
||||||
|
|
||||||
public string CmdPrompt(string p)
|
public string CmdPrompt(string p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -411,6 +411,7 @@ namespace OpenSim.Framework.Servers
|
||||||
/// That is something that cannot be determined within this class. So
|
/// That is something that cannot be determined within this class. So
|
||||||
/// all attempts to use the console MUST be verified.
|
/// all attempts to use the console MUST be verified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="msg"></param>
|
||||||
protected void Notice(string msg)
|
protected void Notice(string msg)
|
||||||
{
|
{
|
||||||
if (m_console != null)
|
if (m_console != null)
|
||||||
|
@ -418,6 +419,19 @@ namespace OpenSim.Framework.Servers
|
||||||
m_console.Output(msg);
|
m_console.Output(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Console output is only possible if a console has been established.
|
||||||
|
/// That is something that cannot be determined within this class. So
|
||||||
|
/// all attempts to use the console MUST be verified.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format"></param>
|
||||||
|
/// <param name="components"></param>
|
||||||
|
protected void Notice(string format, params string[] components)
|
||||||
|
{
|
||||||
|
if (m_console != null)
|
||||||
|
m_console.OutputFormat(format, components);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enhance the version string with extra information if it's available.
|
/// Enhance the version string with extra information if it's available.
|
||||||
|
|
|
@ -324,16 +324,19 @@ namespace OpenSim
|
||||||
"Restart all sims in this instance", RunCommand);
|
"Restart all sims in this instance", RunCommand);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "config set",
|
m_console.Commands.AddCommand("region", false, "config set",
|
||||||
"config set <section> <field> <value>",
|
"config set <section> <key> <value>",
|
||||||
"Set a config option", HandleConfig);
|
"Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "config get",
|
m_console.Commands.AddCommand("region", false, "config get",
|
||||||
"config get <section> <field>",
|
"config get [<section>] [<key>]",
|
||||||
"Read a config option", HandleConfig);
|
"Show a config option",
|
||||||
|
"If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine
|
||||||
|
+ "If a section is given but not a field, then all fields in that section are printed.",
|
||||||
|
HandleConfig);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "config save",
|
m_console.Commands.AddCommand("region", false, "config save",
|
||||||
"config save",
|
"config save <path>",
|
||||||
"Save current configuration", HandleConfig);
|
"Save current configuration to a file at the given path", HandleConfig);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "command-script",
|
m_console.Commands.AddCommand("region", false, "command-script",
|
||||||
"command-script <script>",
|
"command-script <script>",
|
||||||
|
@ -575,7 +578,6 @@ namespace OpenSim
|
||||||
List<string> args = new List<string>(cmd);
|
List<string> args = new List<string>(cmd);
|
||||||
args.RemoveAt(0);
|
args.RemoveAt(0);
|
||||||
string[] cmdparams = args.ToArray();
|
string[] cmdparams = args.ToArray();
|
||||||
string n = "CONFIG";
|
|
||||||
|
|
||||||
if (cmdparams.Length > 0)
|
if (cmdparams.Length > 0)
|
||||||
{
|
{
|
||||||
|
@ -584,8 +586,8 @@ namespace OpenSim
|
||||||
case "set":
|
case "set":
|
||||||
if (cmdparams.Length < 4)
|
if (cmdparams.Length < 4)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("SYNTAX: {0} SET SECTION KEY VALUE",n));
|
Notice("Syntax: config set <section> <key> <value>");
|
||||||
MainConsole.Instance.Output(String.Format("EXAMPLE: {0} SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5",n));
|
Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -598,48 +600,68 @@ namespace OpenSim
|
||||||
c.Set(cmdparams[2], _value);
|
c.Set(cmdparams[2], _value);
|
||||||
m_config.Source.Merge(source);
|
m_config.Source.Merge(source);
|
||||||
|
|
||||||
MainConsole.Instance.Output(String.Format("{0} {0} {1} {2} {3}",n,cmdparams[1],cmdparams[2],_value));
|
Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "get":
|
case "get":
|
||||||
if (cmdparams.Length < 3)
|
if (cmdparams.Length == 1)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("SYNTAX: {0} GET SECTION KEY",n));
|
foreach (IConfig config in m_config.Source.Configs)
|
||||||
MainConsole.Instance.Output(String.Format("EXAMPLE: {0} GET ScriptEngine.DotNetEngine NumberOfScriptThreads",n));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IConfig c = m_config.Source.Configs[cmdparams[1]];
|
|
||||||
if (c == null)
|
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("Section \"{0}\" does not exist.",cmdparams[1]));
|
Notice("[{0}]", config.Name);
|
||||||
|
string[] keys = config.GetKeys();
|
||||||
|
foreach (string key in keys)
|
||||||
|
Notice(" {0} = {1}", key, config.GetString(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cmdparams.Length == 2 || cmdparams.Length == 3)
|
||||||
|
{
|
||||||
|
IConfig config = m_config.Source.Configs[cmdparams[1]];
|
||||||
|
if (config == null)
|
||||||
|
{
|
||||||
|
Notice("Section \"{0}\" does not exist.",cmdparams[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output(String.Format("{0} GET {1} {2} : {3}",n,cmdparams[1],cmdparams[2],
|
if (cmdparams.Length == 2)
|
||||||
c.GetString(cmdparams[2])));
|
{
|
||||||
|
Notice("[{0}]", config.Name);
|
||||||
|
foreach (string key in config.GetKeys())
|
||||||
|
Notice(" {0} = {1}", key, config.GetString(key));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notice(
|
||||||
|
"config get {0} {1} : {2}",
|
||||||
|
cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notice("Syntax: config get [<section>] [<key>]");
|
||||||
|
Notice("Example: config get ScriptEngine.DotNetEngine NumberOfScriptThreads");
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "save":
|
case "save":
|
||||||
if (cmdparams.Length < 2)
|
if (cmdparams.Length < 2)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output("SYNTAX: " + n + " SAVE FILE");
|
Notice("Syntax: config save <path>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Application.iniFilePath == cmdparams[1])
|
if (Application.iniFilePath == cmdparams[1])
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Output("FILE can not be " + Application.iniFilePath);
|
Notice("Path can not be " + Application.iniFilePath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainConsole.Instance.Output("Saving configuration file: " + cmdparams[1]);
|
Notice("Saving configuration file: " + cmdparams[1]);
|
||||||
m_config.Save(cmdparams[1]);
|
m_config.Save(cmdparams[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue