diff options
author | Justin Clark-Casey (justincc) | 2011-01-21 23:59:55 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-01-21 23:59:55 +0000 |
commit | cb14e1d2720fdee0c77280d7c397c02116c278ca (patch) | |
tree | 0c899fb54c3e26423dffa1377eba426f1bd79b4c /OpenSim/Region/Application/OpenSim.cs | |
parent | remove some mono compiler warnings (diff) | |
download | opensim-SC_OLD-cb14e1d2720fdee0c77280d7c397c02116c278ca.zip opensim-SC_OLD-cb14e1d2720fdee0c77280d7c397c02116c278ca.tar.gz opensim-SC_OLD-cb14e1d2720fdee0c77280d7c397c02116c278ca.tar.bz2 opensim-SC_OLD-cb14e1d2720fdee0c77280d7c397c02116c278ca.tar.xz |
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 issues
Diffstat (limited to 'OpenSim/Region/Application/OpenSim.cs')
-rw-r--r-- | OpenSim/Region/Application/OpenSim.cs | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 00a97be..ed4b620 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -324,16 +324,19 @@ namespace OpenSim | |||
324 | "Restart all sims in this instance", RunCommand); | 324 | "Restart all sims in this instance", RunCommand); |
325 | 325 | ||
326 | m_console.Commands.AddCommand("region", false, "config set", | 326 | m_console.Commands.AddCommand("region", false, "config set", |
327 | "config set <section> <field> <value>", | 327 | "config set <section> <key> <value>", |
328 | "Set a config option", HandleConfig); | 328 | "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); |
329 | 329 | ||
330 | m_console.Commands.AddCommand("region", false, "config get", | 330 | m_console.Commands.AddCommand("region", false, "config get", |
331 | "config get <section> <field>", | 331 | "config get [<section>] [<key>]", |
332 | "Read a config option", HandleConfig); | 332 | "Show a config option", |
333 | "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine | ||
334 | + "If a section is given but not a field, then all fields in that section are printed.", | ||
335 | HandleConfig); | ||
333 | 336 | ||
334 | m_console.Commands.AddCommand("region", false, "config save", | 337 | m_console.Commands.AddCommand("region", false, "config save", |
335 | "config save", | 338 | "config save <path>", |
336 | "Save current configuration", HandleConfig); | 339 | "Save current configuration to a file at the given path", HandleConfig); |
337 | 340 | ||
338 | m_console.Commands.AddCommand("region", false, "command-script", | 341 | m_console.Commands.AddCommand("region", false, "command-script", |
339 | "command-script <script>", | 342 | "command-script <script>", |
@@ -575,7 +578,6 @@ namespace OpenSim | |||
575 | List<string> args = new List<string>(cmd); | 578 | List<string> args = new List<string>(cmd); |
576 | args.RemoveAt(0); | 579 | args.RemoveAt(0); |
577 | string[] cmdparams = args.ToArray(); | 580 | string[] cmdparams = args.ToArray(); |
578 | string n = "CONFIG"; | ||
579 | 581 | ||
580 | if (cmdparams.Length > 0) | 582 | if (cmdparams.Length > 0) |
581 | { | 583 | { |
@@ -584,8 +586,8 @@ namespace OpenSim | |||
584 | case "set": | 586 | case "set": |
585 | if (cmdparams.Length < 4) | 587 | if (cmdparams.Length < 4) |
586 | { | 588 | { |
587 | MainConsole.Instance.Output(String.Format("SYNTAX: {0} SET SECTION KEY VALUE",n)); | 589 | Notice("Syntax: config set <section> <key> <value>"); |
588 | MainConsole.Instance.Output(String.Format("EXAMPLE: {0} SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5",n)); | 590 | Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); |
589 | } | 591 | } |
590 | else | 592 | else |
591 | { | 593 | { |
@@ -598,48 +600,68 @@ namespace OpenSim | |||
598 | c.Set(cmdparams[2], _value); | 600 | c.Set(cmdparams[2], _value); |
599 | m_config.Source.Merge(source); | 601 | m_config.Source.Merge(source); |
600 | 602 | ||
601 | MainConsole.Instance.Output(String.Format("{0} {0} {1} {2} {3}",n,cmdparams[1],cmdparams[2],_value)); | 603 | Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value); |
602 | } | 604 | } |
603 | } | 605 | } |
604 | break; | 606 | break; |
605 | 607 | ||
606 | case "get": | 608 | case "get": |
607 | if (cmdparams.Length < 3) | 609 | if (cmdparams.Length == 1) |
608 | { | 610 | { |
609 | MainConsole.Instance.Output(String.Format("SYNTAX: {0} GET SECTION KEY",n)); | 611 | foreach (IConfig config in m_config.Source.Configs) |
610 | MainConsole.Instance.Output(String.Format("EXAMPLE: {0} GET ScriptEngine.DotNetEngine NumberOfScriptThreads",n)); | 612 | { |
613 | Notice("[{0}]", config.Name); | ||
614 | string[] keys = config.GetKeys(); | ||
615 | foreach (string key in keys) | ||
616 | Notice(" {0} = {1}", key, config.GetString(key)); | ||
617 | } | ||
611 | } | 618 | } |
612 | else | 619 | else if (cmdparams.Length == 2 || cmdparams.Length == 3) |
613 | { | 620 | { |
614 | IConfig c = m_config.Source.Configs[cmdparams[1]]; | 621 | IConfig config = m_config.Source.Configs[cmdparams[1]]; |
615 | if (c == null) | 622 | if (config == null) |
616 | { | 623 | { |
617 | MainConsole.Instance.Output(String.Format("Section \"{0}\" does not exist.",cmdparams[1])); | 624 | Notice("Section \"{0}\" does not exist.",cmdparams[1]); |
618 | break; | 625 | break; |
619 | } | 626 | } |
620 | else | 627 | else |
621 | { | 628 | { |
622 | MainConsole.Instance.Output(String.Format("{0} GET {1} {2} : {3}",n,cmdparams[1],cmdparams[2], | 629 | if (cmdparams.Length == 2) |
623 | c.GetString(cmdparams[2]))); | 630 | { |
631 | Notice("[{0}]", config.Name); | ||
632 | foreach (string key in config.GetKeys()) | ||
633 | Notice(" {0} = {1}", key, config.GetString(key)); | ||
634 | } | ||
635 | else | ||
636 | { | ||
637 | Notice( | ||
638 | "config get {0} {1} : {2}", | ||
639 | cmdparams[1], cmdparams[2], config.GetString(cmdparams[2])); | ||
640 | } | ||
624 | } | 641 | } |
625 | } | 642 | } |
643 | else | ||
644 | { | ||
645 | Notice("Syntax: config get [<section>] [<key>]"); | ||
646 | Notice("Example: config get ScriptEngine.DotNetEngine NumberOfScriptThreads"); | ||
647 | } | ||
626 | 648 | ||
627 | break; | 649 | break; |
628 | 650 | ||
629 | case "save": | 651 | case "save": |
630 | if (cmdparams.Length < 2) | 652 | if (cmdparams.Length < 2) |
631 | { | 653 | { |
632 | MainConsole.Instance.Output("SYNTAX: " + n + " SAVE FILE"); | 654 | Notice("Syntax: config save <path>"); |
633 | return; | 655 | return; |
634 | } | 656 | } |
635 | 657 | ||
636 | if (Application.iniFilePath == cmdparams[1]) | 658 | if (Application.iniFilePath == cmdparams[1]) |
637 | { | 659 | { |
638 | MainConsole.Instance.Output("FILE can not be " + Application.iniFilePath); | 660 | Notice("Path can not be " + Application.iniFilePath); |
639 | return; | 661 | return; |
640 | } | 662 | } |
641 | 663 | ||
642 | MainConsole.Instance.Output("Saving configuration file: " + cmdparams[1]); | 664 | Notice("Saving configuration file: " + cmdparams[1]); |
643 | m_config.Save(cmdparams[1]); | 665 | m_config.Save(cmdparams[1]); |
644 | break; | 666 | break; |
645 | } | 667 | } |